mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Store centric UI: Part 3 (#3224)
* Set store context in cookie * Fix page id usages in view * Move Pay Button to nav * Move integrations to plugins nav * Store switch links to wallet if present * Test fixes * Nav fixes * Fix altcoin view * Main nav updates * Wallet setttings nav update * Move storeId cookie fallback to cookie auth handler * View fixes * Test fixes * Fix profile check * Rename integrations nav extension point to store-integrations-nav-list * Allow strings for Active page/category for plugins * Make invoice list filter based on store context * Do not set context if we are running authorizer through tag helper * Fix test and unfiltered invoices * Add permission helper for wallet links * Add sanity checks for payment requests and invoices * Store context in home controller * Fix PayjoinViaUI test * Store context for notifications * Minor UI improvements * Store context for userstores and vault controller * Bring back integrations page * Rename notifications nav pages file * Fix user stores controller policies * Controller policy fixes from code review * CookieAuthHandler: Simplify CanViewInvoices case * Revert "Controller policy fixes from code review" This reverts commit 97e8b8379c2f2f373bac15a96632d2c8913ef4bd. * Simplify LayoutSimple * Fix CanViewInvoices condition Co-authored-by: Kukks <evilkukka@gmail.com>
This commit is contained in:
@@ -16,6 +16,7 @@ using BTCPayServer.Models.StoreViewModels;
|
||||
using BTCPayServer.Security;
|
||||
using BTCPayServer.Services;
|
||||
using BTCPayServer.Services.Apps;
|
||||
using BTCPayServer.Services.Stores;
|
||||
using ExchangeSharp;
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -26,6 +27,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using NBitcoin;
|
||||
using NBitcoin.Payment;
|
||||
using NBitpayClient;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
@@ -34,44 +36,59 @@ namespace BTCPayServer.Controllers
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ISettingsRepository _settingsRepository;
|
||||
private readonly StoreRepository _storeRepository;
|
||||
private readonly IFileProvider _fileProvider;
|
||||
|
||||
public IHttpClientFactory HttpClientFactory { get; }
|
||||
private IHttpClientFactory HttpClientFactory { get; }
|
||||
private SignInManager<ApplicationUser> SignInManager { get; }
|
||||
public LanguageService LanguageService { get; }
|
||||
SignInManager<ApplicationUser> SignInManager { get; }
|
||||
|
||||
public HomeController(IHttpClientFactory httpClientFactory,
|
||||
ISettingsRepository settingsRepository,
|
||||
IWebHostEnvironment webHostEnvironment,
|
||||
LanguageService languageService,
|
||||
StoreRepository storeRepository,
|
||||
SignInManager<ApplicationUser> signInManager)
|
||||
{
|
||||
_settingsRepository = settingsRepository;
|
||||
HttpClientFactory = httpClientFactory;
|
||||
LanguageService = languageService;
|
||||
_storeRepository = storeRepository;
|
||||
_fileProvider = webHostEnvironment.WebRootFileProvider;
|
||||
SignInManager = signInManager;
|
||||
}
|
||||
|
||||
[Route("")]
|
||||
[DomainMappingConstraint()]
|
||||
[DomainMappingConstraint]
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
if ((await _settingsRepository.GetTheme()).FirstRun)
|
||||
{
|
||||
return RedirectToAction(nameof(AccountController.Register), "Account");
|
||||
}
|
||||
|
||||
if (SignInManager.IsSignedIn(User))
|
||||
{
|
||||
var storeId = HttpContext.GetUserPrefsCookie()?.CurrentStoreId;
|
||||
if (storeId != null)
|
||||
{
|
||||
var userId = SignInManager.UserManager.GetUserId(HttpContext.User);
|
||||
var store = await _storeRepository.FindStore(storeId, userId);
|
||||
if (store != null)
|
||||
{
|
||||
HttpContext.SetStoreData(store);
|
||||
}
|
||||
}
|
||||
return View("Home");
|
||||
else
|
||||
return Challenge();
|
||||
}
|
||||
|
||||
return Challenge();
|
||||
}
|
||||
|
||||
[Route("misc/lang")]
|
||||
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Cookie + "," + AuthenticationSchemes.Greenfield)]
|
||||
public IActionResult Languages()
|
||||
{
|
||||
return Json(LanguageService.GetLanguages(), new JsonSerializerSettings() { Formatting = Formatting.Indented });
|
||||
return Json(LanguageService.GetLanguages(), new JsonSerializerSettings { Formatting = Formatting.Indented });
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +96,7 @@ namespace BTCPayServer.Controllers
|
||||
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Cookie + "," + AuthenticationSchemes.Greenfield)]
|
||||
public IActionResult Permissions()
|
||||
{
|
||||
return Json(Client.Models.PermissionMetadata.PermissionNodes, new JsonSerializerSettings() { Formatting = Formatting.Indented });
|
||||
return Json(Client.Models.PermissionMetadata.PermissionNodes, new JsonSerializerSettings { Formatting = Formatting.Indented });
|
||||
}
|
||||
|
||||
[Route("swagger/v1/swagger.json")]
|
||||
@@ -108,7 +125,7 @@ namespace BTCPayServer.Controllers
|
||||
}
|
||||
|
||||
[Route("recovery-seed-backup")]
|
||||
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Cookie)]
|
||||
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Cookie, Policy = Policies.CanModifyStoreSettings)]
|
||||
public IActionResult RecoverySeedBackup(RecoverySeedBackupViewModel vm)
|
||||
{
|
||||
return View("RecoverySeedBackup", vm);
|
||||
|
||||
Reference in New Issue
Block a user