mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Convert to file-scoped namespace
This commit is contained in:
@@ -24,141 +24,140 @@ using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.Extensions.Options;
|
||||
using StoreData = BTCPayServer.Data.StoreData;
|
||||
|
||||
namespace BTCPayServer.Controllers
|
||||
namespace BTCPayServer.Controllers;
|
||||
|
||||
[Route("stores")]
|
||||
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Cookie)]
|
||||
[Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Cookie)]
|
||||
[AutoValidateAntiforgeryToken]
|
||||
public partial class UIStoresController : Controller
|
||||
{
|
||||
[Route("stores")]
|
||||
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Cookie)]
|
||||
[Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Cookie)]
|
||||
[AutoValidateAntiforgeryToken]
|
||||
public partial class UIStoresController : Controller
|
||||
public UIStoresController(
|
||||
BTCPayServerOptions btcpayServerOptions,
|
||||
BTCPayServerEnvironment btcpayEnv,
|
||||
StoreRepository storeRepo,
|
||||
TokenRepository tokenRepo,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
BitpayAccessTokenController tokenController,
|
||||
BTCPayWalletProvider walletProvider,
|
||||
BTCPayNetworkProvider networkProvider,
|
||||
RateFetcher rateFactory,
|
||||
ExplorerClientProvider explorerProvider,
|
||||
LanguageService langService,
|
||||
PaymentMethodHandlerDictionary paymentMethodHandlerDictionary,
|
||||
PoliciesSettings policiesSettings,
|
||||
IAuthorizationService authorizationService,
|
||||
AppService appService,
|
||||
IFileService fileService,
|
||||
WebhookSender webhookNotificationManager,
|
||||
IDataProtectionProvider dataProtector,
|
||||
IOptions<LightningNetworkOptions> lightningNetworkOptions,
|
||||
IOptions<ExternalServicesOptions> externalServiceOptions,
|
||||
IHtmlHelper html,
|
||||
EmailSenderFactory emailSenderFactory,
|
||||
WalletFileParsers onChainWalletParsers,
|
||||
SettingsRepository settingsRepository,
|
||||
EventAggregator eventAggregator)
|
||||
{
|
||||
public UIStoresController(
|
||||
BTCPayServerOptions btcpayServerOptions,
|
||||
BTCPayServerEnvironment btcpayEnv,
|
||||
StoreRepository storeRepo,
|
||||
TokenRepository tokenRepo,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
BitpayAccessTokenController tokenController,
|
||||
BTCPayWalletProvider walletProvider,
|
||||
BTCPayNetworkProvider networkProvider,
|
||||
RateFetcher rateFactory,
|
||||
ExplorerClientProvider explorerProvider,
|
||||
LanguageService langService,
|
||||
PaymentMethodHandlerDictionary paymentMethodHandlerDictionary,
|
||||
PoliciesSettings policiesSettings,
|
||||
IAuthorizationService authorizationService,
|
||||
AppService appService,
|
||||
IFileService fileService,
|
||||
WebhookSender webhookNotificationManager,
|
||||
IDataProtectionProvider dataProtector,
|
||||
IOptions<LightningNetworkOptions> lightningNetworkOptions,
|
||||
IOptions<ExternalServicesOptions> externalServiceOptions,
|
||||
IHtmlHelper html,
|
||||
EmailSenderFactory emailSenderFactory,
|
||||
WalletFileParsers onChainWalletParsers,
|
||||
SettingsRepository settingsRepository,
|
||||
EventAggregator eventAggregator)
|
||||
{
|
||||
_rateFactory = rateFactory;
|
||||
_storeRepo = storeRepo;
|
||||
_tokenRepository = tokenRepo;
|
||||
_userManager = userManager;
|
||||
_langService = langService;
|
||||
_tokenController = tokenController;
|
||||
_walletProvider = walletProvider;
|
||||
_handlers = paymentMethodHandlerDictionary;
|
||||
_policiesSettings = policiesSettings;
|
||||
_authorizationService = authorizationService;
|
||||
_appService = appService;
|
||||
_fileService = fileService;
|
||||
_networkProvider = networkProvider;
|
||||
_explorerProvider = explorerProvider;
|
||||
_btcpayServerOptions = btcpayServerOptions;
|
||||
_btcPayEnv = btcpayEnv;
|
||||
_externalServiceOptions = externalServiceOptions;
|
||||
_emailSenderFactory = emailSenderFactory;
|
||||
_onChainWalletParsers = onChainWalletParsers;
|
||||
_settingsRepository = settingsRepository;
|
||||
_eventAggregator = eventAggregator;
|
||||
_html = html;
|
||||
_dataProtector = dataProtector.CreateProtector("ConfigProtector");
|
||||
_webhookNotificationManager = webhookNotificationManager;
|
||||
_lightningNetworkOptions = lightningNetworkOptions.Value;
|
||||
}
|
||||
_rateFactory = rateFactory;
|
||||
_storeRepo = storeRepo;
|
||||
_tokenRepository = tokenRepo;
|
||||
_userManager = userManager;
|
||||
_langService = langService;
|
||||
_tokenController = tokenController;
|
||||
_walletProvider = walletProvider;
|
||||
_handlers = paymentMethodHandlerDictionary;
|
||||
_policiesSettings = policiesSettings;
|
||||
_authorizationService = authorizationService;
|
||||
_appService = appService;
|
||||
_fileService = fileService;
|
||||
_networkProvider = networkProvider;
|
||||
_explorerProvider = explorerProvider;
|
||||
_btcpayServerOptions = btcpayServerOptions;
|
||||
_btcPayEnv = btcpayEnv;
|
||||
_externalServiceOptions = externalServiceOptions;
|
||||
_emailSenderFactory = emailSenderFactory;
|
||||
_onChainWalletParsers = onChainWalletParsers;
|
||||
_settingsRepository = settingsRepository;
|
||||
_eventAggregator = eventAggregator;
|
||||
_html = html;
|
||||
_dataProtector = dataProtector.CreateProtector("ConfigProtector");
|
||||
_webhookNotificationManager = webhookNotificationManager;
|
||||
_lightningNetworkOptions = lightningNetworkOptions.Value;
|
||||
}
|
||||
|
||||
private readonly BTCPayServerOptions _btcpayServerOptions;
|
||||
private readonly BTCPayServerEnvironment _btcPayEnv;
|
||||
private readonly BTCPayNetworkProvider _networkProvider;
|
||||
private readonly BTCPayWalletProvider _walletProvider;
|
||||
private readonly BitpayAccessTokenController _tokenController;
|
||||
private readonly StoreRepository _storeRepo;
|
||||
private readonly TokenRepository _tokenRepository;
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
private readonly RateFetcher _rateFactory;
|
||||
private readonly SettingsRepository _settingsRepository;
|
||||
private readonly ExplorerClientProvider _explorerProvider;
|
||||
private readonly LanguageService _langService;
|
||||
private readonly PaymentMethodHandlerDictionary _handlers;
|
||||
private readonly PoliciesSettings _policiesSettings;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly AppService _appService;
|
||||
private readonly IFileService _fileService;
|
||||
private readonly IOptions<ExternalServicesOptions> _externalServiceOptions;
|
||||
private readonly EmailSenderFactory _emailSenderFactory;
|
||||
private readonly WalletFileParsers _onChainWalletParsers;
|
||||
private readonly EventAggregator _eventAggregator;
|
||||
private readonly IHtmlHelper _html;
|
||||
private readonly WebhookSender _webhookNotificationManager;
|
||||
private readonly LightningNetworkOptions _lightningNetworkOptions;
|
||||
private readonly IDataProtector _dataProtector;
|
||||
private readonly BTCPayServerOptions _btcpayServerOptions;
|
||||
private readonly BTCPayServerEnvironment _btcPayEnv;
|
||||
private readonly BTCPayNetworkProvider _networkProvider;
|
||||
private readonly BTCPayWalletProvider _walletProvider;
|
||||
private readonly BitpayAccessTokenController _tokenController;
|
||||
private readonly StoreRepository _storeRepo;
|
||||
private readonly TokenRepository _tokenRepository;
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
private readonly RateFetcher _rateFactory;
|
||||
private readonly SettingsRepository _settingsRepository;
|
||||
private readonly ExplorerClientProvider _explorerProvider;
|
||||
private readonly LanguageService _langService;
|
||||
private readonly PaymentMethodHandlerDictionary _handlers;
|
||||
private readonly PoliciesSettings _policiesSettings;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly AppService _appService;
|
||||
private readonly IFileService _fileService;
|
||||
private readonly IOptions<ExternalServicesOptions> _externalServiceOptions;
|
||||
private readonly EmailSenderFactory _emailSenderFactory;
|
||||
private readonly WalletFileParsers _onChainWalletParsers;
|
||||
private readonly EventAggregator _eventAggregator;
|
||||
private readonly IHtmlHelper _html;
|
||||
private readonly WebhookSender _webhookNotificationManager;
|
||||
private readonly LightningNetworkOptions _lightningNetworkOptions;
|
||||
private readonly IDataProtector _dataProtector;
|
||||
|
||||
public string? GeneratedPairingCode { get; set; }
|
||||
public string? GeneratedPairingCode { get; set; }
|
||||
|
||||
[TempData]
|
||||
private bool StoreNotConfigured { get; set; }
|
||||
[TempData]
|
||||
private bool StoreNotConfigured { get; set; }
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet("{storeId}/index")]
|
||||
public async Task<IActionResult> Index(string storeId)
|
||||
{
|
||||
var userId = _userManager.GetUserId(User);
|
||||
if (string.IsNullOrEmpty(userId))
|
||||
return Forbid();
|
||||
|
||||
var store = await _storeRepo.FindStore(storeId);
|
||||
if (store is null)
|
||||
return NotFound();
|
||||
|
||||
if ((await _authorizationService.AuthorizeAsync(User, Policies.CanModifyStoreSettings)).Succeeded)
|
||||
{
|
||||
return RedirectToAction("Dashboard", new { storeId });
|
||||
}
|
||||
if ((await _authorizationService.AuthorizeAsync(User, Policies.CanViewInvoices)).Succeeded)
|
||||
{
|
||||
return RedirectToAction("ListInvoices", "UIInvoice", new { storeId });
|
||||
}
|
||||
[AllowAnonymous]
|
||||
[HttpGet("{storeId}/index")]
|
||||
public async Task<IActionResult> Index(string storeId)
|
||||
{
|
||||
var userId = _userManager.GetUserId(User);
|
||||
if (string.IsNullOrEmpty(userId))
|
||||
return Forbid();
|
||||
|
||||
var store = await _storeRepo.FindStore(storeId);
|
||||
if (store is null)
|
||||
return NotFound();
|
||||
|
||||
if ((await _authorizationService.AuthorizeAsync(User, Policies.CanModifyStoreSettings)).Succeeded)
|
||||
{
|
||||
return RedirectToAction("Dashboard", new { storeId });
|
||||
}
|
||||
if ((await _authorizationService.AuthorizeAsync(User, Policies.CanViewInvoices)).Succeeded)
|
||||
{
|
||||
return RedirectToAction("ListInvoices", "UIInvoice", new { storeId });
|
||||
}
|
||||
return Forbid();
|
||||
}
|
||||
|
||||
public StoreData CurrentStore => HttpContext.GetStoreData();
|
||||
public StoreData CurrentStore => HttpContext.GetStoreData();
|
||||
|
||||
public PaymentMethodOptionViewModel.Format[] GetEnabledPaymentMethodChoices(StoreData storeData)
|
||||
{
|
||||
var enabled = storeData.GetEnabledPaymentIds();
|
||||
public PaymentMethodOptionViewModel.Format[] GetEnabledPaymentMethodChoices(StoreData storeData)
|
||||
{
|
||||
var enabled = storeData.GetEnabledPaymentIds();
|
||||
|
||||
return enabled
|
||||
.Select(o =>
|
||||
new PaymentMethodOptionViewModel.Format()
|
||||
{
|
||||
Name = o.ToString(),
|
||||
Value = o.ToString(),
|
||||
PaymentId = o
|
||||
}).ToArray();
|
||||
}
|
||||
return enabled
|
||||
.Select(o =>
|
||||
new PaymentMethodOptionViewModel.Format()
|
||||
{
|
||||
Name = o.ToString(),
|
||||
Value = o.ToString(),
|
||||
PaymentId = o
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
private string? GetUserId()
|
||||
{
|
||||
return User.Identity?.AuthenticationType != AuthenticationSchemes.Cookie ? null : _userManager.GetUserId(User);
|
||||
}
|
||||
private string? GetUserId()
|
||||
{
|
||||
return User.Identity?.AuthenticationType != AuthenticationSchemes.Cookie ? null : _userManager.GetUserId(User);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user