From aad586232caee820594865c803a4ef0b94657cfc Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Thu, 31 Oct 2019 12:29:59 +0900 Subject: [PATCH] Refactor StatusMessage and remove ExternalLogin --- BTCPayServer.Tests/BTCPayServerTester.cs | 1 + BTCPayServer.Tests/Extensions.cs | 2 + BTCPayServer.Tests/SeleniumTester.cs | 1 + BTCPayServer.Tests/UnitTest1.cs | 5 +- .../Configuration/BTCPayServerOptions.cs | 5 + BTCPayServer/Controllers/AccountController.cs | 82 -------------- .../Controllers/AppsController.Crowdfund.cs | 2 +- .../Controllers/AppsController.PointOfSale.cs | 2 +- BTCPayServer/Controllers/AppsController.cs | 16 ++- .../Controllers/InvoiceController.UI.cs | 27 +---- .../Controllers/ManageController.U2F.cs | 2 +- BTCPayServer/Controllers/ManageController.cs | 102 ++---------------- .../Controllers/PaymentRequestController.cs | 7 +- BTCPayServer/Controllers/ServerController.cs | 61 +++++------ .../Controllers/StoresController.BTCLike.cs | 14 +-- .../Controllers/StoresController.Changelly.cs | 6 +- .../StoresController.CoinSwitch.cs | 2 +- .../Controllers/StoresController.Email.cs | 8 +- .../StoresController.LightningLike.cs | 6 +- BTCPayServer/Controllers/StoresController.cs | 38 +++---- .../Controllers/UserStoresController.cs | 7 +- .../Controllers/WalletsController.PSBT.cs | 4 +- BTCPayServer/Controllers/WalletsController.cs | 6 +- BTCPayServer/Extensions.cs | 8 ++ .../ExternalLoginViewModel.cs | 15 --- .../AppViewModels/ViewCrowdfundViewModel.cs | 1 - .../InvoicingModels/InvoiceDetailsModel.cs | 5 - .../Models/InvoicingModels/InvoicesModel.cs | 2 - .../ChangePasswordViewModel.cs | 2 - .../ExternalLoginsViewModel.cs | 20 ---- .../Models/ManageViewModels/IndexViewModel.cs | 5 - .../ManageViewModels/SetPasswordViewModel.cs | 2 - .../ListPaymentRequestsViewModel.cs | 3 - .../ServerViewModels/EmailsViewModel.cs | 4 - .../Models/ServerViewModels/LogsViewModel.cs | 6 -- .../Models/ServerViewModels/UserViewModel.cs | 1 - .../Models/ServerViewModels/UsersViewModel.cs | 1 - .../DerivationSchemeViewModel.cs | 1 - .../StoreViewModels/LightningNodeViewModel.cs | 1 - .../Models/StoreViewModels/TokensViewModel.cs | 5 - .../UpdateChangellySettingsViewModel.cs | 2 - .../UpdateCoinSwitchSettingsViewModel.cs | 2 - BTCPayServer/Properties/launchSettings.json | 6 +- .../Monero/UI/MoneroLikeStoreController.cs | 7 +- BTCPayServer/Services/Apps/AppService.cs | 1 - .../U2F/Models/U2FAuthenticationViewModel.cs | 1 - .../Views/Account/ExternalLogin.cshtml | 32 ------ BTCPayServer/Views/Apps/ListApps.cshtml | 4 +- .../Views/Apps/UpdateCrowdfund.cshtml | 4 +- .../Views/Apps/UpdatePointOfSale.cshtml | 4 +- BTCPayServer/Views/Invoice/Invoice.cshtml | 4 +- .../Views/Invoice/ListInvoices.cshtml | 4 +- .../Views/Manage/ChangePassword.cshtml | 2 +- .../Views/Manage/ExternalLogins.cshtml | 51 --------- BTCPayServer/Views/Manage/Index.cshtml | 3 +- BTCPayServer/Views/Manage/ManageNavPages.cs | 2 +- BTCPayServer/Views/Manage/SetPassword.cshtml | 2 +- .../Views/Manage/U2FAuthentication.cshtml | 2 +- BTCPayServer/Views/Manage/_Nav.cshtml | 7 -- .../GetStoreMoneroLikePaymentMethod.cshtml | 2 +- .../GetStoreMoneroLikePaymentMethods.cshtml | 2 +- .../PaymentRequest/EditPaymentRequest.cshtml | 4 +- .../PaymentRequest/GetPaymentRequests.cshtml | 4 +- .../PaymentRequest/ViewPaymentRequest.cshtml | 2 +- BTCPayServer/Views/Server/ListUsers.cshtml | 2 +- BTCPayServer/Views/Server/Logs.cshtml | 2 +- BTCPayServer/Views/Server/User.cshtml | 2 +- BTCPayServer/Views/Shared/EmailsBody.cshtml | 2 +- .../Views/Shared/_StatusMessage.cshtml | 27 ++++- .../Views/Stores/AddDerivationScheme.cshtml | 2 +- .../Views/Stores/AddLightningNode.cshtml | 2 +- BTCPayServer/Views/Stores/ListTokens.cshtml | 2 +- .../Stores/UpdateChangellySettings.cshtml | 2 +- .../Stores/UpdateCoinSwitchSettings.cshtml | 2 +- BTCPayServer/WellKnownTempData.cs | 14 +++ 75 files changed, 185 insertions(+), 516 deletions(-) delete mode 100644 BTCPayServer/Models/AccountViewModels/ExternalLoginViewModel.cs delete mode 100644 BTCPayServer/Models/ManageViewModels/ExternalLoginsViewModel.cs delete mode 100644 BTCPayServer/Views/Account/ExternalLogin.cshtml delete mode 100644 BTCPayServer/Views/Manage/ExternalLogins.cshtml create mode 100644 BTCPayServer/WellKnownTempData.cs diff --git a/BTCPayServer.Tests/BTCPayServerTester.cs b/BTCPayServer.Tests/BTCPayServerTester.cs index e02ab94e2..9babf373b 100644 --- a/BTCPayServer.Tests/BTCPayServerTester.cs +++ b/BTCPayServer.Tests/BTCPayServerTester.cs @@ -118,6 +118,7 @@ namespace BTCPayServer.Tests config.AppendLine($"ltc.explorer.url={LTCNBXplorerUri.AbsoluteUri}"); config.AppendLine($"ltc.explorer.cookiefile=0"); config.AppendLine($"btc.lightning={IntegratedLightning.AbsoluteUri}"); + config.AppendLine($"debuglog=debug.log"); if (!string.IsNullOrEmpty(SSHPassword) && string.IsNullOrEmpty(SSHKeyFile)) config.AppendLine($"sshpassword={SSHPassword}"); if (!string.IsNullOrEmpty(SSHKeyFile)) diff --git a/BTCPayServer.Tests/Extensions.cs b/BTCPayServer.Tests/Extensions.cs index 55249c829..6d3c9a799 100644 --- a/BTCPayServer.Tests/Extensions.cs +++ b/BTCPayServer.Tests/Extensions.cs @@ -28,6 +28,8 @@ namespace BTCPayServer.Tests try { Assert.NotEmpty(driver.FindElements(By.ClassName("navbar-brand"))); + foreach (var dangerAlert in driver.FindElements(By.ClassName("alert-danger"))) + Assert.False(dangerAlert.Displayed, "No alert should be displayed"); } catch { diff --git a/BTCPayServer.Tests/SeleniumTester.cs b/BTCPayServer.Tests/SeleniumTester.cs index eba70f3e4..170d2082a 100644 --- a/BTCPayServer.Tests/SeleniumTester.cs +++ b/BTCPayServer.Tests/SeleniumTester.cs @@ -142,6 +142,7 @@ namespace BTCPayServer.Tests Assert.NotEmpty(links); foreach (var l in links) { + Logs.Tester.LogInformation($"Checking no error on {l}"); Driver.Navigate().GoToUrl(l); Driver.AssertNoError(); } diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index e9dc22143..de9be1379 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -551,7 +551,8 @@ namespace BTCPayServer.Tests ConnectionString = "type=charge;server=" + tester.MerchantCharge.Client.Uri.AbsoluteUri, SkipPortTest = true // We can't test this as the IP can't be resolved by the test host :( }, "test", "BTC").GetAwaiter().GetResult(); - Assert.DoesNotContain("Error", ((LightningNodeViewModel)Assert.IsType(testResult).Model).StatusMessage, StringComparison.OrdinalIgnoreCase); + Assert.False(storeController.TempData.ContainsKey(WellKnownTempData.ErrorMessage)); + storeController.TempData.Clear(); Assert.True(storeController.ModelState.IsValid); Assert.IsType(storeController.AddLightningNode(user.StoreId, new LightningNodeViewModel() @@ -746,7 +747,7 @@ namespace BTCPayServer.Tests acc.CreateStore(); var store2 = acc.GetController(); await store2.Pair(pairingCode.ToString(), store2.CurrentStore.Id); - Assert.Contains(nameof(PairingResult.ReusedKey), store2.StatusMessage, StringComparison.CurrentCultureIgnoreCase); + Assert.Contains(nameof(PairingResult.ReusedKey), (string)store2.TempData[WellKnownTempData.ErrorMessage], StringComparison.CurrentCultureIgnoreCase); } } diff --git a/BTCPayServer/Configuration/BTCPayServerOptions.cs b/BTCPayServer/Configuration/BTCPayServerOptions.cs index 124883957..438168473 100644 --- a/BTCPayServer/Configuration/BTCPayServerOptions.cs +++ b/BTCPayServer/Configuration/BTCPayServerOptions.cs @@ -207,6 +207,11 @@ namespace BTCPayServer.Configuration LogFile = GetDebugLog(conf); if (!string.IsNullOrEmpty(LogFile)) + { + if (!Path.IsPathRooted(LogFile)) + LogFile = Path.Combine(DataDir, LogFile); + } + if (!string.IsNullOrEmpty(LogFile)) { Logs.Configuration.LogInformation("LogFile: " + LogFile); Logs.Configuration.LogInformation("Log Level: " + GetDebugLogLevel(conf)); diff --git a/BTCPayServer/Controllers/AccountController.cs b/BTCPayServer/Controllers/AccountController.cs index ab40e637f..a5ee28a99 100644 --- a/BTCPayServer/Controllers/AccountController.cs +++ b/BTCPayServer/Controllers/AccountController.cs @@ -447,88 +447,6 @@ namespace BTCPayServer.Controllers return RedirectToAction(nameof(HomeController.Index), "Home"); } - [HttpPost] - [AllowAnonymous] - [ValidateAntiForgeryToken] - public IActionResult ExternalLogin(string provider, string returnUrl = null) - { - // Request a redirect to the external login provider. - var redirectUrl = Url.Action(nameof(ExternalLoginCallback), "Account", new - { - returnUrl - }); - var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl); - return Challenge(properties, provider); - } - - [HttpGet] - [AllowAnonymous] - public async Task ExternalLoginCallback(string returnUrl = null, string remoteError = null) - { - if (remoteError != null) - { - ErrorMessage = $"Error from external provider: {remoteError}"; - return RedirectToAction(nameof(Login)); - } - var info = await _signInManager.GetExternalLoginInfoAsync(); - if (info == null) - { - return RedirectToAction(nameof(Login)); - } - - // Sign in the user with this external login provider if the user already has a login. - var result = await _signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey, isPersistent: false, bypassTwoFactor: true); - if (result.Succeeded) - { - _logger.LogInformation("User logged in with {Name} provider.", info.LoginProvider); - return RedirectToLocal(returnUrl); - } - if (result.IsLockedOut) - { - return RedirectToAction(nameof(Lockout)); - } - else - { - // If the user does not have an account, then ask the user to create an account. - ViewData["ReturnUrl"] = returnUrl; - ViewData["LoginProvider"] = info.LoginProvider; - var email = info.Principal.FindFirstValue(ClaimTypes.Email); - return View("ExternalLogin", new ExternalLoginViewModel { Email = email }); - } - } - - [HttpPost] - [AllowAnonymous] - [ValidateAntiForgeryToken] - public async Task ExternalLoginConfirmation(ExternalLoginViewModel model, string returnUrl = null) - { - if (ModelState.IsValid) - { - // Get the information about the user from the external login provider - var info = await _signInManager.GetExternalLoginInfoAsync(); - if (info == null) - { - throw new ApplicationException("Error loading external login information during confirmation."); - } - var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; - var result = await _userManager.CreateAsync(user); - if (result.Succeeded) - { - result = await _userManager.AddLoginAsync(user, info); - if (result.Succeeded) - { - await _signInManager.SignInAsync(user, isPersistent: false); - _logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider); - return RedirectToLocal(returnUrl); - } - } - AddErrors(result); - } - - ViewData["ReturnUrl"] = returnUrl; - return View(nameof(ExternalLogin), model); - } - [HttpGet] [AllowAnonymous] public async Task ConfirmEmail(string userId, string code) diff --git a/BTCPayServer/Controllers/AppsController.Crowdfund.cs b/BTCPayServer/Controllers/AppsController.Crowdfund.cs index 5e7a50303..267d26f46 100644 --- a/BTCPayServer/Controllers/AppsController.Crowdfund.cs +++ b/BTCPayServer/Controllers/AppsController.Crowdfund.cs @@ -164,7 +164,7 @@ namespace BTCPayServer.Controllers StoreId = app.StoreDataId, Settings = newSettings }); - StatusMessage = "App updated"; + TempData[WellKnownTempData.SuccessMessage] = "App updated"; return RedirectToAction(nameof(UpdateCrowdfund), new {appId}); } } diff --git a/BTCPayServer/Controllers/AppsController.PointOfSale.cs b/BTCPayServer/Controllers/AppsController.PointOfSale.cs index 9f345d4b2..51032b52f 100644 --- a/BTCPayServer/Controllers/AppsController.PointOfSale.cs +++ b/BTCPayServer/Controllers/AppsController.PointOfSale.cs @@ -201,7 +201,7 @@ namespace BTCPayServer.Controllers }); await _AppService.UpdateOrCreateApp(app); - StatusMessage = "App updated"; + TempData[WellKnownTempData.SuccessMessage] = "App updated"; return RedirectToAction(nameof(UpdatePointOfSale), new { appId }); } diff --git a/BTCPayServer/Controllers/AppsController.cs b/BTCPayServer/Controllers/AppsController.cs index 3a876356d..516c2a5ea 100644 --- a/BTCPayServer/Controllers/AppsController.cs +++ b/BTCPayServer/Controllers/AppsController.cs @@ -50,8 +50,6 @@ namespace BTCPayServer.Controllers private readonly EmailSenderFactory _emailSenderFactory; private AppService _AppService; - [TempData] - public string StatusMessage { get; set; } public string CreatedAppId { get; set; } public async Task ListApps() @@ -71,7 +69,7 @@ namespace BTCPayServer.Controllers if (appData == null) return NotFound(); if (await _AppService.DeleteApp(appData)) - StatusMessage = "App removed successfully"; + TempData[WellKnownTempData.SuccessMessage] = "App removed successfully"; return RedirectToAction(nameof(ListApps)); } @@ -82,12 +80,12 @@ namespace BTCPayServer.Controllers var stores = await _AppService.GetOwnedStores(GetUserId()); if (stores.Length == 0) { - StatusMessage = new StatusMessageModel() + TempData[WellKnownTempData.StatusMessageModel] = new StatusMessageModel() { Html = $"Error: You need to create at least one store. Create store", Severity = StatusMessageModel.StatusSeverity.Error - }.ToString(); + }; return RedirectToAction(nameof(ListApps)); } var vm = new CreateAppViewModel(); @@ -102,12 +100,12 @@ namespace BTCPayServer.Controllers var stores = await _AppService.GetOwnedStores(GetUserId()); if (stores.Length == 0) { - StatusMessage = new StatusMessageModel() + TempData[WellKnownTempData.StatusMessageModel] = new StatusMessageModel() { Html = $"Error: You need to create at least one store. Create store", Severity = StatusMessageModel.StatusSeverity.Error - }.ToString(); + }; return RedirectToAction(nameof(ListApps)); } var selectedStore = vm.SelectedStore; @@ -124,7 +122,7 @@ namespace BTCPayServer.Controllers if (!stores.Any(s => s.Id == selectedStore)) { - StatusMessage = "Error: You are not owner of this store"; + TempData[WellKnownTempData.ErrorMessage] = "You are not owner of this store"; return RedirectToAction(nameof(ListApps)); } var appData = new AppData @@ -134,7 +132,7 @@ namespace BTCPayServer.Controllers AppType = appType.ToString() }; await _AppService.UpdateOrCreateApp(appData); - StatusMessage = "App successfully created"; + TempData[WellKnownTempData.SuccessMessage] = "App successfully created"; CreatedAppId = appData.Id; switch (appType) diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index 96f8c9196..7a261de96 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -71,9 +71,7 @@ namespace BTCPayServer.Controllers ProductInformation = invoice.ProductInformation, StatusException = invoice.ExceptionStatus, Events = invoice.Events, - PosData = PosDataParser.ParsePosData(invoice.PosData), - StatusMessage = StatusMessage, - + PosData = PosDataParser.ParsePosData(invoice.PosData) }; model.Addresses = invoice.HistoricalAddresses.Select(h => @@ -405,7 +403,6 @@ namespace BTCPayServer.Controllers SearchTerm = searchTerm, Skip = skip, Count = count, - StatusMessage = StatusMessage, TimezoneOffset = timezoneOffset }; InvoiceQuery invoiceQuery = GetInvoiceQuery(searchTerm, timezoneOffset); @@ -497,7 +494,7 @@ namespace BTCPayServer.Controllers var stores = new SelectList(await _StoreRepository.GetStoresByUserId(GetUserId()), nameof(StoreData.Id), nameof(StoreData.StoreName), null); if (stores.Count() == 0) { - StatusMessage = "Error: You need to create at least one store before creating a transaction"; + TempData[WellKnownTempData.ErrorMessage] = "You need to create at least one store before creating a transaction"; return RedirectToAction(nameof(UserStoresController.ListStores), "UserStores"); } @@ -518,22 +515,13 @@ namespace BTCPayServer.Controllers { return View(model); } - StatusMessage = null; + if (store.GetSupportedPaymentMethods(_NetworkProvider).Count() == 0) { ModelState.AddModelError(nameof(model.StoreId), "You need to configure the derivation scheme in order to create an invoice"); return View(model); } - - if (StatusMessage != null) - { - return RedirectToAction(nameof(StoresController.UpdateStore), "Stores", new - { - storeId = store.Id - }); - } - try { var result = await CreateInvoiceCore(new CreateInvoiceRequest() @@ -554,7 +542,7 @@ namespace BTCPayServer.Controllers }) }, store, HttpContext.Request.GetAbsoluteRoot(), cancellationToken: cancellationToken); - StatusMessage = $"Invoice {result.Data.Id} just created!"; + TempData[WellKnownTempData.SuccessMessage] = $"Invoice {result.Data.Id} just created!"; return RedirectToAction(nameof(ListInvoices)); } catch (BitpayHttpException ex) @@ -603,13 +591,6 @@ namespace BTCPayServer.Controllers public string StatusString { get; set; } } - [TempData] - public string StatusMessage - { - get; - set; - } - private string GetUserId() { return _UserManager.GetUserId(User); diff --git a/BTCPayServer/Controllers/ManageController.U2F.cs b/BTCPayServer/Controllers/ManageController.U2F.cs index eefbb5e55..262c3c938 100644 --- a/BTCPayServer/Controllers/ManageController.U2F.cs +++ b/BTCPayServer/Controllers/ManageController.U2F.cs @@ -11,9 +11,9 @@ namespace BTCPayServer.Controllers [HttpGet] public async Task U2FAuthentication(string statusMessage = null) { + TempData[WellKnownTempData.SuccessMessage] = statusMessage; return View(new U2FAuthenticationViewModel() { - StatusMessage = statusMessage, Devices = await _u2FService.GetDevices(_userManager.GetUserId(User)) }); } diff --git a/BTCPayServer/Controllers/ManageController.cs b/BTCPayServer/Controllers/ManageController.cs index 69eb3d94c..0e55fd1f7 100644 --- a/BTCPayServer/Controllers/ManageController.cs +++ b/BTCPayServer/Controllers/ManageController.cs @@ -64,12 +64,6 @@ namespace BTCPayServer.Controllers _StoreRepository = storeRepository; } - [TempData] - public string StatusMessage - { - get; set; - } - [HttpGet] public async Task Index() { @@ -84,8 +78,7 @@ namespace BTCPayServer.Controllers Username = user.UserName, Email = user.Email, PhoneNumber = user.PhoneNumber, - IsEmailConfirmed = user.EmailConfirmed, - StatusMessage = StatusMessage + IsEmailConfirmed = user.EmailConfirmed }; return View(model); } @@ -137,7 +130,7 @@ namespace BTCPayServer.Controllers } } - StatusMessage = "Your profile has been updated"; + TempData[WellKnownTempData.SuccessMessage] = "Your profile has been updated"; return RedirectToAction(nameof(Index)); } @@ -160,7 +153,7 @@ namespace BTCPayServer.Controllers var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme); var email = user.Email; _EmailSenderFactory.GetEmailSender().SendEmailConfirmation(email, callbackUrl); - StatusMessage = "Verification email sent. Please check your email."; + TempData[WellKnownTempData.SuccessMessage] = "Verification email sent. Please check your email."; return RedirectToAction(nameof(Index)); } @@ -179,7 +172,7 @@ namespace BTCPayServer.Controllers return RedirectToAction(nameof(SetPassword)); } - var model = new ChangePasswordViewModel { StatusMessage = StatusMessage }; + var model = new ChangePasswordViewModel(); return View(model); } @@ -207,7 +200,7 @@ namespace BTCPayServer.Controllers await _signInManager.SignInAsync(user, isPersistent: false); _logger.LogInformation("User changed their password successfully."); - StatusMessage = "Your password has been changed."; + TempData[WellKnownTempData.SuccessMessage] = "Your password has been changed."; return RedirectToAction(nameof(ChangePassword)); } @@ -228,7 +221,7 @@ namespace BTCPayServer.Controllers return RedirectToAction(nameof(ChangePassword)); } - var model = new SetPasswordViewModel { StatusMessage = StatusMessage }; + var model = new SetPasswordViewModel(); return View(model); } @@ -255,92 +248,11 @@ namespace BTCPayServer.Controllers } await _signInManager.SignInAsync(user, isPersistent: false); - StatusMessage = "Your password has been set."; + TempData[WellKnownTempData.SuccessMessage] = "Your password has been set."; return RedirectToAction(nameof(SetPassword)); } - [HttpGet] - public async Task ExternalLogins() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - var model = new ExternalLoginsViewModel { CurrentLogins = await _userManager.GetLoginsAsync(user) }; - model.OtherLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()) - .Where(auth => model.CurrentLogins.All(ul => auth.Name != ul.LoginProvider)) - .ToList(); - model.ShowRemoveButton = await _userManager.HasPasswordAsync(user) || model.CurrentLogins.Count > 1; - model.StatusMessage = StatusMessage; - - return View(model); - } - - [HttpPost] - [ValidateAntiForgeryToken] - public async Task LinkLogin(string provider) - { - // Clear the existing external cookie to ensure a clean login process - await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); - - // Request a redirect to the external login provider to link a login for the current user - var redirectUrl = Url.Action(nameof(LinkLoginCallback)); - var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl, _userManager.GetUserId(User)); - return new ChallengeResult(provider, properties); - } - - [HttpGet] - public async Task LinkLoginCallback() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - var info = await _signInManager.GetExternalLoginInfoAsync(user.Id); - if (info == null) - { - throw new ApplicationException($"Unexpected error occurred loading external login info for user with ID '{user.Id}'."); - } - - var result = await _userManager.AddLoginAsync(user, info); - if (!result.Succeeded) - { - throw new ApplicationException($"Unexpected error occurred adding external login for user with ID '{user.Id}'."); - } - - // Clear the existing external cookie to ensure a clean login process - await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); - - StatusMessage = "The external login was added."; - return RedirectToAction(nameof(ExternalLogins)); - } - - [HttpPost] - [ValidateAntiForgeryToken] - public async Task RemoveLogin(RemoveLoginViewModel model) - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - var result = await _userManager.RemoveLoginAsync(user, model.LoginProvider, model.ProviderKey); - if (!result.Succeeded) - { - throw new ApplicationException($"Unexpected error occurred removing external login for user with ID '{user.Id}'."); - } - - await _signInManager.SignInAsync(user, isPersistent: false); - StatusMessage = "The external login was removed."; - return RedirectToAction(nameof(ExternalLogins)); - } - #region Helpers diff --git a/BTCPayServer/Controllers/PaymentRequestController.cs b/BTCPayServer/Controllers/PaymentRequestController.cs index 68f784829..1b42a49a7 100644 --- a/BTCPayServer/Controllers/PaymentRequestController.cs +++ b/BTCPayServer/Controllers/PaymentRequestController.cs @@ -72,10 +72,10 @@ namespace BTCPayServer.Controllers { UserId = GetUserId(), Skip = skip, Count = count }); + TempData[WellKnownTempData.SuccessMessage] = statusMessage; return View(new ListPaymentRequestsViewModel() { Skip = skip, - StatusMessage = statusMessage, Count = count, Total = result.Total, Items = result.Items.Select(data => new ViewPaymentRequestViewModel(data)).ToList() @@ -111,8 +111,7 @@ namespace BTCPayServer.Controllers return View(new UpdatePaymentRequestViewModel(data) { - Stores = stores, - StatusMessage = statusMessage + Stores = stores }); } @@ -225,8 +224,6 @@ namespace BTCPayServer.Controllers return NotFound(); } result.HubPath = PaymentRequestHub.GetHubPath(this.Request); - result.StatusMessage = statusMessage; - return View(result); } diff --git a/BTCPayServer/Controllers/ServerController.cs b/BTCPayServer/Controllers/ServerController.cs index dced40a18..405281ae3 100644 --- a/BTCPayServer/Controllers/ServerController.cs +++ b/BTCPayServer/Controllers/ServerController.cs @@ -136,7 +136,7 @@ namespace BTCPayServer.Controllers return View(vm); } await _SettingsRepository.UpdateSetting(rates); - StatusMessage = "Rate settings successfully updated"; + TempData[WellKnownTempData.SuccessMessage] = "Rate settings successfully updated"; return RedirectToAction(nameof(Rates)); } @@ -158,7 +158,6 @@ namespace BTCPayServer.Controllers public IActionResult ListUsers(int skip = 0, int count = 50) { var users = new UsersViewModel(); - users.StatusMessage = StatusMessage; users.Users = _UserManager.Users.Skip(skip).Take(count) .Select(u => new UsersViewModel.UserViewModel { @@ -263,21 +262,21 @@ namespace BTCPayServer.Controllers builder.Path = null; builder.Query = null; - StatusMessage = $"Domain name changing... the server will restart, please use \"{builder.Uri.AbsoluteUri}\""; + TempData[WellKnownTempData.SuccessMessage] = $"Domain name changing... the server will restart, please use \"{builder.Uri.AbsoluteUri}\""; } else if (command == "update") { var error = await RunSSH(vm, $"btcpay-update.sh"); if (error != null) return error; - StatusMessage = $"The server might restart soon if an update is available..."; + TempData[WellKnownTempData.SuccessMessage] = $"The server might restart soon if an update is available..."; } else if (command == "clean") { var error = await RunSSH(vm, $"btcpay-clean.sh"); if (error != null) return error; - StatusMessage = $"The old docker images will be cleaned soon..."; + TempData[WellKnownTempData.SuccessMessage] = $"The old docker images will be cleaned soon..."; } else { @@ -357,12 +356,10 @@ namespace BTCPayServer.Controllers if (user == null) return NotFound(); - viewModel.StatusMessage = ""; - var admins = await _UserManager.GetUsersInRoleAsync(Roles.ServerAdmin); if (!viewModel.IsAdmin && admins.Count == 1) { - viewModel.StatusMessage = "This is the only Admin, so their role can't be removed until another Admin is added."; + TempData[WellKnownTempData.ErrorMessage] = "This is the only Admin, so their role can't be removed until another Admin is added."; return View(viewModel); // return } @@ -374,10 +371,10 @@ namespace BTCPayServer.Controllers else await _UserManager.RemoveFromRoleAsync(user, Roles.ServerAdmin); - viewModel.StatusMessage = "User successfully updated"; + TempData[WellKnownTempData.SuccessMessage] = "User successfully updated"; } - return View(viewModel); + return RedirectToAction(nameof(User), new { userId = userId }); } @@ -420,15 +417,9 @@ namespace BTCPayServer.Controllers return NotFound(); await _UserManager.DeleteAsync(user); await _StoreRepository.CleanUnreachableStores(); - StatusMessage = "User deleted"; + TempData[WellKnownTempData.SuccessMessage] = "User deleted"; return RedirectToAction(nameof(ListUsers)); } - - [TempData] - public string StatusMessage - { - get; set; - } public IHttpClientFactory HttpClientFactory { get; } [Route("server/policies")] @@ -591,7 +582,7 @@ namespace BTCPayServer.Controllers { if (!_dashBoard.IsFullySynched(cryptoCode, out var unusud)) { - StatusMessage = $"Error: {cryptoCode} is not fully synched"; + TempData[WellKnownTempData.ErrorMessage] = $"{cryptoCode} is not fully synched"; return RedirectToAction(nameof(Services)); } var service = GetService(serviceName, cryptoCode); @@ -618,7 +609,7 @@ namespace BTCPayServer.Controllers case ExternalServiceTypes.Spark: if (connectionString.AccessKey == null) { - StatusMessage = $"Error: The access key of the service is not set"; + TempData[WellKnownTempData.ErrorMessage] = $"The access key of the service is not set"; return RedirectToAction(nameof(Services)); } LightningWalletServices vm = new LightningWalletServices(); @@ -635,7 +626,7 @@ namespace BTCPayServer.Controllers } catch (Exception ex) { - StatusMessage = $"Error: {ex.Message}"; + TempData[WellKnownTempData.ErrorMessage] = ex.Message; return RedirectToAction(nameof(Services)); } } @@ -715,7 +706,7 @@ namespace BTCPayServer.Controllers { if (!_dashBoard.IsFullySynched(cryptoCode, out var unusud)) { - StatusMessage = $"Error: {cryptoCode} is not fully synched"; + TempData[WellKnownTempData.ErrorMessage] = $"{cryptoCode} is not fully synched"; return RedirectToAction(nameof(Services)); } var service = GetService(serviceName, cryptoCode); @@ -729,7 +720,7 @@ namespace BTCPayServer.Controllers } catch (Exception ex) { - StatusMessage = $"Error: {ex.Message}"; + TempData[WellKnownTempData.ErrorMessage] = ex.Message; return RedirectToAction(nameof(Services)); } @@ -811,7 +802,7 @@ namespace BTCPayServer.Controllers string errorMessage = await viewModel.Settings.SendUpdateRequest(HttpClientFactory.CreateClient()); if (errorMessage == null) { - StatusMessage = $"The Dynamic DNS has been successfully queried, your configuration is saved"; + TempData[WellKnownTempData.SuccessMessage] = $"The Dynamic DNS has been successfully queried, your configuration is saved"; viewModel.Settings.LastUpdated = DateTimeOffset.UtcNow; settings.Services.Add(viewModel.Settings); await _SettingsRepository.UpdateSetting(settings); @@ -847,7 +838,7 @@ namespace BTCPayServer.Controllers viewModel.Settings.Hostname = viewModel.Settings.Hostname.Trim().ToLowerInvariant(); if (!viewModel.Settings.Enabled) { - StatusMessage = $"The Dynamic DNS service has been disabled"; + TempData[WellKnownTempData.SuccessMessage] = $"The Dynamic DNS service has been disabled"; viewModel.Settings.LastUpdated = null; } else @@ -855,7 +846,7 @@ namespace BTCPayServer.Controllers string errorMessage = await viewModel.Settings.SendUpdateRequest(HttpClientFactory.CreateClient()); if (errorMessage == null) { - StatusMessage = $"The Dynamic DNS has been successfully queried, your configuration is saved"; + TempData[WellKnownTempData.SuccessMessage] = $"The Dynamic DNS has been successfully queried, your configuration is saved"; viewModel.Settings.LastUpdated = DateTimeOffset.UtcNow; } else @@ -894,7 +885,7 @@ namespace BTCPayServer.Controllers return NotFound(); settings.Services.RemoveAt(i); await _SettingsRepository.UpdateSetting(settings); - StatusMessage = "Dynamic DNS service successfully removed"; + TempData[WellKnownTempData.SuccessMessage] = "Dynamic DNS service successfully removed"; this.RouteData.Values.Remove(nameof(hostname)); return RedirectToAction(nameof(DynamicDnsServices)); } @@ -965,7 +956,7 @@ namespace BTCPayServer.Controllers try { await System.IO.File.WriteAllTextAsync(_Options.SSHSettings.AuthorizedKeysFile, newContent); - StatusMessage = "authorized_keys has been updated"; + TempData[WellKnownTempData.SuccessMessage] = "authorized_keys has been updated"; updated = true; } catch (Exception ex) @@ -994,11 +985,11 @@ namespace BTCPayServer.Controllers if (exception is null) { - StatusMessage = "authorized_keys has been updated"; + TempData[WellKnownTempData.SuccessMessage] = "authorized_keys has been updated"; } else { - StatusMessage = $"Error: {exception.Message}"; + TempData[WellKnownTempData.ErrorMessage] = exception.Message; } return RedirectToAction(nameof(SSHService)); } @@ -1032,7 +1023,7 @@ namespace BTCPayServer.Controllers { if (!model.Settings.IsComplete()) { - model.StatusMessage = "Error: Required fields missing"; + TempData[WellKnownTempData.ErrorMessage] = "Required fields missing"; return View(model); } @@ -1043,18 +1034,18 @@ namespace BTCPayServer.Controllers var client = model.Settings.CreateSmtpClient(); var message = model.Settings.CreateMailMessage(new MailAddress(model.TestEmail), "BTCPay test", "BTCPay test"); await client.SendMailAsync(message); - model.StatusMessage = "Email sent to " + model.TestEmail + ", please, verify you received it"; + TempData[WellKnownTempData.SuccessMessage] = "Email sent to " + model.TestEmail + ", please, verify you received it"; } catch (Exception ex) { - model.StatusMessage = "Error: " + ex.Message; + TempData[WellKnownTempData.ErrorMessage] = ex.Message; } return View(model); } else // if(command == "Save") { await _SettingsRepository.UpdateSetting(model.Settings); - model.StatusMessage = "Email settings saved"; + TempData[WellKnownTempData.SuccessMessage] = "Email settings saved"; return View(model); } } @@ -1071,7 +1062,7 @@ namespace BTCPayServer.Controllers if (string.IsNullOrEmpty(_Options.LogFile)) { - vm.StatusMessage = "Error: File Logging Option not specified. " + + TempData[WellKnownTempData.ErrorMessage] = "File Logging Option not specified. " + "You need to set debuglog and optionally " + "debugloglevel in the configuration or through runtime arguments"; } @@ -1080,7 +1071,7 @@ namespace BTCPayServer.Controllers var di = Directory.GetParent(_Options.LogFile); if (di == null) { - vm.StatusMessage = "Error: Could not load log files"; + TempData[WellKnownTempData.ErrorMessage] = "Could not load log files"; } var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(_Options.LogFile); diff --git a/BTCPayServer/Controllers/StoresController.BTCLike.cs b/BTCPayServer/Controllers/StoresController.BTCLike.cs index 6f3965303..bec429d93 100644 --- a/BTCPayServer/Controllers/StoresController.BTCLike.cs +++ b/BTCPayServer/Controllers/StoresController.BTCLike.cs @@ -174,11 +174,11 @@ namespace BTCPayServer.Controllers { if (!DerivationSchemeSettings.TryParseFromJson(vm.Config, network, out strategy)) { - vm.StatusMessage = new StatusMessageModel() + TempData[WellKnownTempData.StatusMessageModel] = new StatusMessageModel() { Severity = StatusMessageModel.StatusSeverity.Error, Message = "Config file was not in the correct format" - }.ToString(); + }; vm.Confirmation = false; return View(vm); } @@ -188,11 +188,11 @@ namespace BTCPayServer.Controllers { if (!DerivationSchemeSettings.TryParseFromColdcard(await ReadAllText(vm.ColdcardPublicFile), network, out strategy)) { - vm.StatusMessage = new StatusMessageModel() + TempData[WellKnownTempData.StatusMessageModel] = new StatusMessageModel() { Severity = StatusMessageModel.StatusSeverity.Error, Message = "Coldcard public file was not in the correct format" - }.ToString(); + }; vm.Confirmation = false; return View(vm); } @@ -275,11 +275,11 @@ namespace BTCPayServer.Controllers if (willBeExcluded != wasExcluded) { var label = willBeExcluded ? "disabled" : "enabled"; - StatusMessage = $"On-Chain payments for {network.CryptoCode} has been {label}."; + TempData[WellKnownTempData.SuccessMessage] = $"On-Chain payments for {network.CryptoCode} has been {label}."; } else { - StatusMessage = $"Derivation settings for {network.CryptoCode} has been modified."; + TempData[WellKnownTempData.SuccessMessage] = $"Derivation settings for {network.CryptoCode} has been modified."; } return RedirectToAction(nameof(UpdateStore), new {storeId = storeId}); } @@ -312,7 +312,7 @@ namespace BTCPayServer.Controllers } vm.HintAddress = ""; - vm.StatusMessage = + TempData[WellKnownTempData.SuccessMessage] = "Address successfully found, please verify that the rest is correct and click on \"Confirm\""; ModelState.Remove(nameof(vm.HintAddress)); ModelState.Remove(nameof(vm.DerivationScheme)); diff --git a/BTCPayServer/Controllers/StoresController.Changelly.cs b/BTCPayServer/Controllers/StoresController.Changelly.cs index dad5dbb5f..68b475e33 100644 --- a/BTCPayServer/Controllers/StoresController.Changelly.cs +++ b/BTCPayServer/Controllers/StoresController.Changelly.cs @@ -71,7 +71,7 @@ namespace BTCPayServer.Controllers storeBlob.ChangellySettings = changellySettings; store.SetStoreBlob(storeBlob); await _Repo.UpdateStore(store); - StatusMessage = "Changelly settings modified"; + TempData[WellKnownTempData.SuccessMessage] = "Changelly settings modified"; _changellyClientProvider.InvalidateClient(storeId); return RedirectToAction(nameof(UpdateStore), new { storeId}); @@ -81,12 +81,12 @@ namespace BTCPayServer.Controllers var client = new Changelly(_httpClientFactory.CreateClient(), changellySettings.ApiKey, changellySettings.ApiSecret, changellySettings.ApiUrl); var result = await client.GetCurrenciesFull(); - vm.StatusMessage = "Test Successful"; + TempData[WellKnownTempData.SuccessMessage] = "Test Successful"; return View(vm); } catch (Exception ex) { - vm.StatusMessage = $"Error: {ex.Message}"; + TempData[WellKnownTempData.ErrorMessage] = ex.Message; return View(vm); } default: diff --git a/BTCPayServer/Controllers/StoresController.CoinSwitch.cs b/BTCPayServer/Controllers/StoresController.CoinSwitch.cs index d793c06ab..4b546274b 100644 --- a/BTCPayServer/Controllers/StoresController.CoinSwitch.cs +++ b/BTCPayServer/Controllers/StoresController.CoinSwitch.cs @@ -62,7 +62,7 @@ namespace BTCPayServer.Controllers storeBlob.CoinSwitchSettings = coinSwitchSettings; store.SetStoreBlob(storeBlob); await _Repo.UpdateStore(store); - StatusMessage = "CoinSwitch settings modified"; + TempData[WellKnownTempData.SuccessMessage] = "CoinSwitch settings modified"; return RedirectToAction(nameof(UpdateStore), new { storeId}); diff --git a/BTCPayServer/Controllers/StoresController.Email.cs b/BTCPayServer/Controllers/StoresController.Email.cs index 7735d029f..d3f798c9c 100644 --- a/BTCPayServer/Controllers/StoresController.Email.cs +++ b/BTCPayServer/Controllers/StoresController.Email.cs @@ -36,17 +36,17 @@ namespace BTCPayServer.Controllers { if (!model.Settings.IsComplete()) { - model.StatusMessage = "Error: Required fields missing"; + TempData[WellKnownTempData.ErrorMessage] = "Required fields missing"; return View(model); } var client = model.Settings.CreateSmtpClient(); var message = model.Settings.CreateMailMessage(new MailAddress(model.TestEmail), "BTCPay test", "BTCPay test"); await client.SendMailAsync(message); - model.StatusMessage = "Email sent to " + model.TestEmail + ", please, verify you received it"; + TempData[WellKnownTempData.SuccessMessage] = "Email sent to " + model.TestEmail + ", please, verify you received it"; } catch (Exception ex) { - model.StatusMessage = "Error: " + ex.Message; + TempData[WellKnownTempData.ErrorMessage] = "Error: " + ex.Message; } return View(model); } @@ -57,7 +57,7 @@ namespace BTCPayServer.Controllers storeBlob.EmailSettings = model.Settings; store.SetStoreBlob(storeBlob); await _Repo.UpdateStore(store); - StatusMessage = "Email settings modified"; + TempData[WellKnownTempData.SuccessMessage] = "Email settings modified"; return RedirectToAction(nameof(UpdateStore), new { storeId}); diff --git a/BTCPayServer/Controllers/StoresController.LightningLike.cs b/BTCPayServer/Controllers/StoresController.LightningLike.cs index 0c23c3a8b..8f931c295 100644 --- a/BTCPayServer/Controllers/StoresController.LightningLike.cs +++ b/BTCPayServer/Controllers/StoresController.LightningLike.cs @@ -146,7 +146,7 @@ namespace BTCPayServer.Controllers store.SetStoreBlob(storeBlob); store.SetSupportedPaymentMethod(paymentMethodId, paymentMethod); await _Repo.UpdateStore(store); - StatusMessage = $"Lightning node modified ({network.CryptoCode})"; + TempData[WellKnownTempData.SuccessMessage] = $"Lightning node modified ({network.CryptoCode})"; return RedirectToAction(nameof(UpdateStore), new { storeId = storeId }); case "test" when paymentMethod == null: ModelState.AddModelError(nameof(vm.ConnectionString), "Missing url parameter"); @@ -163,11 +163,11 @@ namespace BTCPayServer.Controllers await handler.TestConnection(info, cts.Token); } } - vm.StatusMessage = $"Connection to the lightning node succeeded ({info})"; + TempData[WellKnownTempData.SuccessMessage] = $"Connection to the lightning node succeeded ({info})"; } catch (Exception ex) { - vm.StatusMessage = $"Error: {ex.Message}"; + TempData[WellKnownTempData.ErrorMessage] = ex.Message; return View(vm); } return View(vm); diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs index 0111b5c05..4ec8334b0 100644 --- a/BTCPayServer/Controllers/StoresController.cs +++ b/BTCPayServer/Controllers/StoresController.cs @@ -102,11 +102,6 @@ namespace BTCPayServer.Controllers private readonly PaymentMethodHandlerDictionary _paymentMethodHandlerDictionary; private readonly CssThemeManager _CssThemeManager; - [TempData] - public string StatusMessage - { - get; set; - } [TempData] public bool StoreNotConfigured { @@ -168,7 +163,7 @@ namespace BTCPayServer.Controllers ModelState.AddModelError(nameof(vm.Email), "The user already has access to this store"); return View(vm); } - StatusMessage = "User added successfully"; + TempData[WellKnownTempData.SuccessMessage] = "User added successfully"; return RedirectToAction(nameof(StoreUsers)); } @@ -193,7 +188,7 @@ namespace BTCPayServer.Controllers public async Task DeleteStoreUserPost(string storeId, string userId) { await _Repo.RemoveStoreUser(storeId, userId); - StatusMessage = "User removed successfully"; + TempData[WellKnownTempData.SuccessMessage] = "User removed successfully"; return RedirectToAction(nameof(StoreUsers), new { storeId = storeId, userId = userId }); } @@ -314,7 +309,7 @@ namespace BTCPayServer.Controllers if (CurrentStore.SetStoreBlob(blob)) { await _Repo.UpdateStore(CurrentStore); - StatusMessage = "Rate settings updated"; + TempData[WellKnownTempData.SuccessMessage] = "Rate settings updated"; } return RedirectToAction(nameof(Rates), new { @@ -347,7 +342,7 @@ namespace BTCPayServer.Controllers blob.RateScript = blob.GetDefaultRateRules(_NetworkProvider).ToString(); CurrentStore.SetStoreBlob(blob); await _Repo.UpdateStore(CurrentStore); - StatusMessage = "Rate rules scripting activated"; + TempData[WellKnownTempData.SuccessMessage] = "Rate rules scripting activated"; return RedirectToAction(nameof(Rates), new { storeId = CurrentStore.Id }); } @@ -434,7 +429,7 @@ namespace BTCPayServer.Controllers if (needUpdate) { await _Repo.UpdateStore(CurrentStore); - StatusMessage = "Store successfully updated"; + TempData[WellKnownTempData.SuccessMessage] = "Store successfully updated"; } return RedirectToAction(nameof(CheckoutExperience), new @@ -563,7 +558,7 @@ namespace BTCPayServer.Controllers if (needUpdate) { await _Repo.UpdateStore(CurrentStore); - StatusMessage = "Store successfully updated"; + TempData[WellKnownTempData.SuccessMessage] = "Store successfully updated"; } return RedirectToAction(nameof(UpdateStore), new @@ -591,7 +586,7 @@ namespace BTCPayServer.Controllers public async Task DeleteStorePost(string storeId) { await _Repo.DeleteStore(CurrentStore.Id); - StatusMessage = "Success: Store successfully deleted"; + TempData[WellKnownTempData.SuccessMessage] = "Store successfully deleted"; return RedirectToAction(nameof(UserStoresController.ListStores), "UserStores"); } @@ -617,7 +612,6 @@ namespace BTCPayServer.Controllers { var model = new TokensViewModel(); var tokens = await _TokenRepository.GetTokensByStoreIdAsync(CurrentStore.Id); - model.StatusMessage = StatusMessage; model.StoreNotConfigured = StoreNotConfigured; model.Tokens = tokens.Select(t => new TokenViewModel() { @@ -657,9 +651,9 @@ namespace BTCPayServer.Controllers if (token == null || token.StoreId != CurrentStore.Id || !await _TokenRepository.DeleteToken(tokenId)) - StatusMessage = "Failure to revoke this token"; + TempData[WellKnownTempData.ErrorMessage] = "Failure to revoke this token"; else - StatusMessage = "Token revoked"; + TempData[WellKnownTempData.SuccessMessage] = "Token revoked"; return RedirectToAction(nameof(ListTokens)); } @@ -749,7 +743,7 @@ namespace BTCPayServer.Controllers model.Stores = new SelectList(stores.Where(s => s.Role == StoreRoles.Owner), nameof(CurrentStore.Id), nameof(CurrentStore.StoreName), storeId); if (model.Stores.Count() == 0) { - StatusMessage = "Error: You need to be owner of at least one store before pairing"; + TempData[WellKnownTempData.ErrorMessage] = "You need to be owner of at least one store before pairing"; return RedirectToAction(nameof(UserStoresController.ListStores), "UserStores"); } } @@ -764,7 +758,7 @@ namespace BTCPayServer.Controllers if (store == null) return NotFound(); await _TokenRepository.GenerateLegacyAPIKey(CurrentStore.Id); - StatusMessage = "API Key re-generated"; + TempData[WellKnownTempData.SuccessMessage] = "API Key re-generated"; return RedirectToAction(nameof(ListTokens)); } @@ -781,7 +775,7 @@ namespace BTCPayServer.Controllers var pairing = await _TokenRepository.GetPairingAsync(pairingCode); if (pairing == null) { - StatusMessage = "Unknown pairing code"; + TempData[WellKnownTempData.ErrorMessage] = "Unknown pairing code"; return RedirectToAction(nameof(UserStoresController.ListStores), "UserStores"); } else @@ -820,9 +814,9 @@ namespace BTCPayServer.Controllers StoreNotConfigured = store.GetSupportedPaymentMethods(_NetworkProvider) .Where(p => !excludeFilter.Match(p.PaymentId)) .Count() == 0; - StatusMessage = "Pairing is successful"; + TempData[WellKnownTempData.SuccessMessage] = "Pairing is successful"; if (pairingResult == PairingResult.Partial) - StatusMessage = "Server initiated pairing code: " + pairingCode; + TempData[WellKnownTempData.SuccessMessage] = "Server initiated pairing code: " + pairingCode; return RedirectToAction(nameof(ListTokens), new { storeId = store.Id, @@ -831,7 +825,7 @@ namespace BTCPayServer.Controllers } else { - StatusMessage = $"Pairing failed ({pairingResult})"; + TempData[WellKnownTempData.ErrorMessage] = $"Pairing failed ({pairingResult})"; return RedirectToAction(nameof(ListTokens), new { storeId = store.Id @@ -889,7 +883,7 @@ namespace BTCPayServer.Controllers if (CurrentStore.SetStoreBlob(blob)) { await _Repo.UpdateStore(CurrentStore); - StatusMessage = "Store successfully updated"; + TempData[WellKnownTempData.SuccessMessage] = "Store successfully updated"; } return RedirectToAction(nameof(PayButton), new diff --git a/BTCPayServer/Controllers/UserStoresController.cs b/BTCPayServer/Controllers/UserStoresController.cs index 201fc9d0a..36a94fe22 100644 --- a/BTCPayServer/Controllers/UserStoresController.cs +++ b/BTCPayServer/Controllers/UserStoresController.cs @@ -71,13 +71,10 @@ namespace BTCPayServer.Controllers if (store == null) return NotFound(); await _Repo.RemoveStore(storeId, userId); - StatusMessage = "Store removed successfully"; + TempData[WellKnownTempData.SuccessMessage] = "Store removed successfully"; return RedirectToAction(nameof(ListStores)); } - [TempData] - public string StatusMessage { get; set; } - [HttpGet] public async Task ListStores() { @@ -107,7 +104,7 @@ namespace BTCPayServer.Controllers } var store = await _Repo.CreateStore(GetUserId(), vm.Name); CreatedStoreId = store.Id; - StatusMessage = "Store successfully created"; + TempData[WellKnownTempData.SuccessMessage] = "Store successfully created"; return RedirectToAction(nameof(StoresController.UpdateStore), "Stores", new { storeId = store.Id diff --git a/BTCPayServer/Controllers/WalletsController.PSBT.cs b/BTCPayServer/Controllers/WalletsController.PSBT.cs index d887590ae..2ce808bef 100644 --- a/BTCPayServer/Controllers/WalletsController.PSBT.cs +++ b/BTCPayServer/Controllers/WalletsController.PSBT.cs @@ -96,7 +96,7 @@ namespace BTCPayServer.Controllers ModelState.AddModelError(nameof(vm.PSBT), "You need to update your version of NBXplorer"); return View(vm); } - StatusMessage = "PSBT updated!"; + TempData[WellKnownTempData.SuccessMessage] = "PSBT updated!"; return RedirectToAction(nameof(WalletPSBT), new { walletId = walletId, psbt = psbt.ToBase64(), FileName = vm.FileName }); case "seed": return SignWithSeed(walletId, psbt.ToBase64()); @@ -353,7 +353,7 @@ namespace BTCPayServer.Controllers return View(vm); } sourcePSBT = sourcePSBT.Combine(psbt); - StatusMessage = "PSBT Successfully combined!"; + TempData[WellKnownTempData.SuccessMessage] = "PSBT Successfully combined!"; return ViewPSBT(sourcePSBT); } } diff --git a/BTCPayServer/Controllers/WalletsController.cs b/BTCPayServer/Controllers/WalletsController.cs index 17b8d11b6..803b62e56 100644 --- a/BTCPayServer/Controllers/WalletsController.cs +++ b/BTCPayServer/Controllers/WalletsController.cs @@ -50,8 +50,6 @@ namespace BTCPayServer.Controllers private readonly IFeeProviderFactory _feeRateProvider; private readonly BTCPayWalletProvider _walletProvider; public RateFetcher RateFetcher { get; } - [TempData] - public string StatusMessage { get; set; } CurrencyNameTable _currencyTable; public WalletsController(StoreRepository repo, @@ -573,7 +571,7 @@ namespace BTCPayServer.Controllers var wallet = _walletProvider.GetWallet(network); var derivationSettings = GetDerivationSchemeSettings(walletId); wallet.InvalidateCache(derivationSettings.AccountDerivation); - StatusMessage = $"Transaction broadcasted successfully ({transaction.GetHash().ToString()})"; + TempData[WellKnownTempData.SuccessMessage] = $"Transaction broadcasted successfully ({transaction.GetHash().ToString()})"; } return RedirectToAction(nameof(WalletTransactions), new { walletId = walletId.ToString() }); } @@ -863,7 +861,7 @@ namespace BTCPayServer.Controllers var store = (await Repository.FindStore(walletId.StoreId, GetUserId())); store.SetSupportedPaymentMethod(derivationScheme); await Repository.UpdateStore(store); - StatusMessage = "Wallet settings updated"; + TempData[WellKnownTempData.SuccessMessage] = "Wallet settings updated"; return RedirectToAction(nameof(WalletSettings)); } } diff --git a/BTCPayServer/Extensions.cs b/BTCPayServer/Extensions.cs index 2599f5392..aeead1ee8 100644 --- a/BTCPayServer/Extensions.cs +++ b/BTCPayServer/Extensions.cs @@ -34,6 +34,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using NBXplorer.DerivationStrategy; using System.Net; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc.ViewFeatures; namespace BTCPayServer { @@ -109,6 +110,13 @@ namespace BTCPayServer } return value; } + + public static bool HasStatusMessage(this ITempDataDictionary tempData) + { + return (tempData.Peek(WellKnownTempData.SuccessMessage) ?? + tempData.Peek(WellKnownTempData.ErrorMessage) ?? + tempData.Peek(WellKnownTempData.StatusMessageModel)) != null; + } public static PaymentMethodId GetpaymentMethodId(this InvoiceCryptoInfo info) { return new PaymentMethodId(info.CryptoCode, PaymentTypes.Parse(info.PaymentType)); diff --git a/BTCPayServer/Models/AccountViewModels/ExternalLoginViewModel.cs b/BTCPayServer/Models/AccountViewModels/ExternalLoginViewModel.cs deleted file mode 100644 index 4110c69cb..000000000 --- a/BTCPayServer/Models/AccountViewModels/ExternalLoginViewModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Threading.Tasks; - -namespace BTCPayServer.Models.AccountViewModels -{ - public class ExternalLoginViewModel - { - [Required] - [EmailAddress] - public string Email { get; set; } - } -} diff --git a/BTCPayServer/Models/AppViewModels/ViewCrowdfundViewModel.cs b/BTCPayServer/Models/AppViewModels/ViewCrowdfundViewModel.cs index ba9cda499..8ad197977 100644 --- a/BTCPayServer/Models/AppViewModels/ViewCrowdfundViewModel.cs +++ b/BTCPayServer/Models/AppViewModels/ViewCrowdfundViewModel.cs @@ -11,7 +11,6 @@ namespace BTCPayServer.Models.AppViewModels public class ViewCrowdfundViewModel { public string HubPath { get; set; } - public string StatusMessage{ get; set; } public string StoreId { get; set; } public string AppId { get; set; } public string Title { get; set; } diff --git a/BTCPayServer/Models/InvoicingModels/InvoiceDetailsModel.cs b/BTCPayServer/Models/InvoicingModels/InvoiceDetailsModel.cs index 36e5e044d..359da32ec 100644 --- a/BTCPayServer/Models/InvoicingModels/InvoiceDetailsModel.cs +++ b/BTCPayServer/Models/InvoicingModels/InvoiceDetailsModel.cs @@ -49,11 +49,6 @@ namespace BTCPayServer.Models.InvoicingModels public string Destination { get; set; } public bool Current { get; set; } } - - public string StatusMessage - { - get; set; - } public String Id { get; set; diff --git a/BTCPayServer/Models/InvoicingModels/InvoicesModel.cs b/BTCPayServer/Models/InvoicingModels/InvoicesModel.cs index 8aa5b0a28..26bcddfed 100644 --- a/BTCPayServer/Models/InvoicingModels/InvoicesModel.cs +++ b/BTCPayServer/Models/InvoicingModels/InvoicesModel.cs @@ -15,7 +15,6 @@ namespace BTCPayServer.Models.InvoicingModels public int? TimezoneOffset { get; set; } public List Invoices { get; set; } = new List(); - public string StatusMessage { get; set; } } public class InvoiceModel @@ -34,7 +33,6 @@ namespace BTCPayServer.Models.InvoicingModels public bool ShowCheckout { get; set; } public string ExceptionStatus { get; set; } public string AmountCurrency { get; set; } - public string StatusMessage { get; set; } public InvoiceDetailsModel Details { get; set; } } diff --git a/BTCPayServer/Models/ManageViewModels/ChangePasswordViewModel.cs b/BTCPayServer/Models/ManageViewModels/ChangePasswordViewModel.cs index 847e0b17f..c5f16c558 100644 --- a/BTCPayServer/Models/ManageViewModels/ChangePasswordViewModel.cs +++ b/BTCPayServer/Models/ManageViewModels/ChangePasswordViewModel.cs @@ -23,7 +23,5 @@ namespace BTCPayServer.Models.ManageViewModels [Display(Name = "Confirm new password")] [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] public string ConfirmPassword { get; set; } - - public string StatusMessage { get; set; } } } diff --git a/BTCPayServer/Models/ManageViewModels/ExternalLoginsViewModel.cs b/BTCPayServer/Models/ManageViewModels/ExternalLoginsViewModel.cs deleted file mode 100644 index 5c5087e59..000000000 --- a/BTCPayServer/Models/ManageViewModels/ExternalLoginsViewModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Identity; - -namespace BTCPayServer.Models.ManageViewModels -{ - public class ExternalLoginsViewModel - { - public IList CurrentLogins { get; set; } - - public IList OtherLogins { get; set; } - - public bool ShowRemoveButton { get; set; } - - public string StatusMessage { get; set; } - } -} diff --git a/BTCPayServer/Models/ManageViewModels/IndexViewModel.cs b/BTCPayServer/Models/ManageViewModels/IndexViewModel.cs index 027bc50c4..425a81b85 100644 --- a/BTCPayServer/Models/ManageViewModels/IndexViewModel.cs +++ b/BTCPayServer/Models/ManageViewModels/IndexViewModel.cs @@ -27,10 +27,5 @@ namespace BTCPayServer.Models.ManageViewModels [MaxLength(50)] public string PhoneNumber { get; set; } - public string StatusMessage - { - get; set; - } - } } diff --git a/BTCPayServer/Models/ManageViewModels/SetPasswordViewModel.cs b/BTCPayServer/Models/ManageViewModels/SetPasswordViewModel.cs index 2d0707425..7679bd6ca 100644 --- a/BTCPayServer/Models/ManageViewModels/SetPasswordViewModel.cs +++ b/BTCPayServer/Models/ManageViewModels/SetPasswordViewModel.cs @@ -18,7 +18,5 @@ namespace BTCPayServer.Models.ManageViewModels [Display(Name = "Confirm new password")] [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] public string ConfirmPassword { get; set; } - - public string StatusMessage { get; set; } } } diff --git a/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs b/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs index 4d3657d09..b20313dd4 100644 --- a/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs +++ b/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs @@ -15,7 +15,6 @@ namespace BTCPayServer.Models.PaymentRequestViewModels public List Items { get; set; } - public string StatusMessage { get; set; } public int Total { get; set; } } @@ -61,7 +60,6 @@ namespace BTCPayServer.Models.PaymentRequestViewModels public DateTime? ExpiryDate { get; set; } [Required] public string Title { get; set; } public string Description { get; set; } - public string StatusMessage { get; set; } public SelectList Stores { get; set; } [EmailAddress] @@ -142,7 +140,6 @@ namespace BTCPayServer.Models.PaymentRequestViewModels public bool AnyPendingInvoice { get; set; } public bool PendingInvoiceHasPayments { get; set; } public string HubPath { get; set; } - public string StatusMessage { get; set; } public class PaymentRequestInvoice { diff --git a/BTCPayServer/Models/ServerViewModels/EmailsViewModel.cs b/BTCPayServer/Models/ServerViewModels/EmailsViewModel.cs index 93e84261d..9a7f249dd 100644 --- a/BTCPayServer/Models/ServerViewModels/EmailsViewModel.cs +++ b/BTCPayServer/Models/ServerViewModels/EmailsViewModel.cs @@ -10,10 +10,6 @@ namespace BTCPayServer.Models.ServerViewModels { public class EmailsViewModel { - public string StatusMessage - { - get; set; - } public EmailSettings Settings { get; set; diff --git a/BTCPayServer/Models/ServerViewModels/LogsViewModel.cs b/BTCPayServer/Models/ServerViewModels/LogsViewModel.cs index 9a05c142f..af6d802ac 100644 --- a/BTCPayServer/Models/ServerViewModels/LogsViewModel.cs +++ b/BTCPayServer/Models/ServerViewModels/LogsViewModel.cs @@ -5,12 +5,6 @@ namespace BTCPayServer.Models.ServerViewModels { public class LogsViewModel { - - public string StatusMessage - { - get; set; - } - public List LogFiles { get; set; } = new List(); public string Log { get; set; } public int LogFileCount { get; set; } diff --git a/BTCPayServer/Models/ServerViewModels/UserViewModel.cs b/BTCPayServer/Models/ServerViewModels/UserViewModel.cs index eddce628f..f399bcf2b 100644 --- a/BTCPayServer/Models/ServerViewModels/UserViewModel.cs +++ b/BTCPayServer/Models/ServerViewModels/UserViewModel.cs @@ -12,6 +12,5 @@ namespace BTCPayServer.Models.ServerViewModels public string Email { get; set; } [Display(Name = "Is admin")] public bool IsAdmin { get; set; } - public string StatusMessage { get; set; } } } diff --git a/BTCPayServer/Models/ServerViewModels/UsersViewModel.cs b/BTCPayServer/Models/ServerViewModels/UsersViewModel.cs index c87eb53fc..a0e6b3127 100644 --- a/BTCPayServer/Models/ServerViewModels/UsersViewModel.cs +++ b/BTCPayServer/Models/ServerViewModels/UsersViewModel.cs @@ -17,7 +17,6 @@ namespace BTCPayServer.Models.ServerViewModels public int Skip { get; set; } public int Count { get; set; } public int Total { get; set; } - public string StatusMessage { get; set; } public List Users { get; set; } = new List(); } diff --git a/BTCPayServer/Models/StoreViewModels/DerivationSchemeViewModel.cs b/BTCPayServer/Models/StoreViewModels/DerivationSchemeViewModel.cs index 298792339..1768eb151 100644 --- a/BTCPayServer/Models/StoreViewModels/DerivationSchemeViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/DerivationSchemeViewModel.cs @@ -32,7 +32,6 @@ namespace BTCPayServer.Models.StoreViewModels public bool Confirmation { get; set; } public bool Enabled { get; set; } = true; - public string StatusMessage { get; internal set; } public KeyPath RootKeyPath { get; set; } [Display(Name = "Coldcard Wallet File")] diff --git a/BTCPayServer/Models/StoreViewModels/LightningNodeViewModel.cs b/BTCPayServer/Models/StoreViewModels/LightningNodeViewModel.cs index 899b69671..4163b9b87 100644 --- a/BTCPayServer/Models/StoreViewModels/LightningNodeViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/LightningNodeViewModel.cs @@ -21,7 +21,6 @@ namespace BTCPayServer.Models.StoreViewModels get; set; } - public string StatusMessage { get; set; } public string InternalLightningNode { get; internal set; } public bool SkipPortTest { get; set; } public bool Enabled { get; set; } = true; diff --git a/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs b/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs index 5071d902d..02fafe041 100644 --- a/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs @@ -53,11 +53,6 @@ namespace BTCPayServer.Models.StoreViewModels { get; set; } - public string StatusMessage - { - get; - set; - } [Display(Name = "API Key")] public string ApiKey { get; set; } diff --git a/BTCPayServer/Models/StoreViewModels/UpdateChangellySettingsViewModel.cs b/BTCPayServer/Models/StoreViewModels/UpdateChangellySettingsViewModel.cs index 27af5575e..e143e7453 100644 --- a/BTCPayServer/Models/StoreViewModels/UpdateChangellySettingsViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/UpdateChangellySettingsViewModel.cs @@ -27,7 +27,5 @@ namespace BTCPayServer.Models.StoreViewModels public decimal AmountMarkupPercentage { get; set; } = new decimal(2); public bool Enabled { get; set; } - - public string StatusMessage { get; set; } } } diff --git a/BTCPayServer/Models/StoreViewModels/UpdateCoinSwitchSettingsViewModel.cs b/BTCPayServer/Models/StoreViewModels/UpdateCoinSwitchSettingsViewModel.cs index fa6c2f001..2ef7fb5e9 100644 --- a/BTCPayServer/Models/StoreViewModels/UpdateCoinSwitchSettingsViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/UpdateCoinSwitchSettingsViewModel.cs @@ -24,7 +24,5 @@ namespace BTCPayServer.Models.StoreViewModels new SelectListItem { Value = "popup", Text = "Open in a popup" }, new SelectListItem { Value = "inline", Text = "Embed inside Checkout UI " }, }; - - public string StatusMessage { get; set; } } } diff --git a/BTCPayServer/Properties/launchSettings.json b/BTCPayServer/Properties/launchSettings.json index 33c27dc8e..824bd3fee 100644 --- a/BTCPayServer/Properties/launchSettings.json +++ b/BTCPayServer/Properties/launchSettings.json @@ -17,7 +17,8 @@ "BTCPAY_DISABLE-REGISTRATION": "false", "ASPNETCORE_ENVIRONMENT": "Development", "BTCPAY_CHAINS": "btc,ltc", - "BTCPAY_POSTGRES": "User ID=postgres;Host=127.0.0.1;Port=39372;Database=btcpayserver" + "BTCPAY_POSTGRES": "User ID=postgres;Host=127.0.0.1;Port=39372;Database=btcpayserver", + "BTCPAY_DEBUGLOG": "debug.log" }, "applicationUrl": "http://127.0.0.1:14142/" }, @@ -44,7 +45,8 @@ "BTCPAY_POSTGRES": "User ID=postgres;Host=127.0.0.1;Port=39372;Database=btcpayserver", "BTCPAY_EXTERNALSERVICES": "totoservice:totolink;", "BTCPAY_SSHCONNECTION": "root@127.0.0.1:21622", - "BTCPAY_SSHPASSWORD": "opD3i2282D" + "BTCPAY_SSHPASSWORD": "opD3i2282D", + "BTCPAY_DEBUGLOG": "debug.log" }, "applicationUrl": "https://localhost:14142/" } diff --git a/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs b/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs index 35ee83c38..b45568aca 100644 --- a/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs +++ b/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs @@ -59,10 +59,9 @@ namespace BTCPayServer.Services.Altcoins.Monero.UI pair => GetAccounts(pair.Key)); await Task.WhenAll(accountsList.Values); - + TempData[WellKnownTempData.SuccessMessage] = statusMessage; return View(new MoneroLikePaymentMethodListViewModel() { - StatusMessage = statusMessage, Items = _MoneroLikeConfiguration.MoneroLikeConfigurationItems.Select(pair => GetMoneroLikePaymentMethodViewModel(monero, pair.Key, excludeFilters, accountsList[pair.Key].Result)) @@ -121,7 +120,7 @@ namespace BTCPayServer.Services.Altcoins.Monero.UI var vm = GetMoneroLikePaymentMethodViewModel(StoreData.GetSupportedPaymentMethods(_BtcPayNetworkProvider) .OfType(), cryptoCode, StoreData.GetStoreBlob().GetExcludedPaymentMethods(), await GetAccounts(cryptoCode)); - vm.StatusMessage = statusMessage; + TempData[WellKnownTempData.SuccessMessage] = statusMessage; return View(nameof(GetStoreMoneroLikePaymentMethod), vm); } @@ -279,13 +278,11 @@ namespace BTCPayServer.Services.Altcoins.Monero.UI public class MoneroLikePaymentMethodListViewModel { - public string StatusMessage { get; set; } public IEnumerable Items { get; set; } } public class MoneroLikePaymentMethodViewModel { - public string StatusMessage { get; set; } public MoneroRPCProvider.MoneroLikeSummary Summary { get; set; } public string CryptoCode { get; set; } public string NewAccountLabel { get; set; } diff --git a/BTCPayServer/Services/Apps/AppService.cs b/BTCPayServer/Services/Apps/AppService.cs index d63e6d645..882ee0c48 100644 --- a/BTCPayServer/Services/Apps/AppService.cs +++ b/BTCPayServer/Services/Apps/AppService.cs @@ -139,7 +139,6 @@ namespace BTCPayServer.Services.Apps TargetAmount = settings.TargetAmount, TargetCurrency = settings.TargetCurrency, EnforceTargetAmount = settings.EnforceTargetAmount, - StatusMessage = statusMessage, Perks = perks, Enabled = settings.Enabled, DisqusEnabled = settings.DisqusEnabled, diff --git a/BTCPayServer/U2F/Models/U2FAuthenticationViewModel.cs b/BTCPayServer/U2F/Models/U2FAuthenticationViewModel.cs index 00f6cf3f9..502964fee 100644 --- a/BTCPayServer/U2F/Models/U2FAuthenticationViewModel.cs +++ b/BTCPayServer/U2F/Models/U2FAuthenticationViewModel.cs @@ -5,7 +5,6 @@ namespace BTCPayServer.U2F.Models { public class U2FAuthenticationViewModel { - public string StatusMessage { get; set; } public List Devices { get; set; } } } diff --git a/BTCPayServer/Views/Account/ExternalLogin.cshtml b/BTCPayServer/Views/Account/ExternalLogin.cshtml deleted file mode 100644 index 0da0eccc9..000000000 --- a/BTCPayServer/Views/Account/ExternalLogin.cshtml +++ /dev/null @@ -1,32 +0,0 @@ -@model ExternalLoginViewModel -@{ - ViewData["Title"] = "Register"; -} - -

@ViewData["Title"]

-

Associate your @ViewData["LoginProvider"] account.

-
- -

- You've successfully authenticated with @ViewData["LoginProvider"]. - Please enter an email address for this site below and click the Register button to finish - logging in. -

- -
-
-
-
-
- - - -
- -
-
-
- -@section Scripts { - @await Html.PartialAsync("_ValidationScriptsPartial") -} diff --git a/BTCPayServer/Views/Apps/ListApps.cshtml b/BTCPayServer/Views/Apps/ListApps.cshtml index e5a54283d..88632663d 100644 --- a/BTCPayServer/Views/Apps/ListApps.cshtml +++ b/BTCPayServer/Views/Apps/ListApps.cshtml @@ -5,11 +5,11 @@ }
- @if (TempData.ContainsKey("TempDataProperty-StatusMessage")) + @if (TempData.HasStatusMessage()) {
- +
} diff --git a/BTCPayServer/Views/Apps/UpdateCrowdfund.cshtml b/BTCPayServer/Views/Apps/UpdateCrowdfund.cshtml index 21d1f12aa..06430ea86 100644 --- a/BTCPayServer/Views/Apps/UpdateCrowdfund.cshtml +++ b/BTCPayServer/Views/Apps/UpdateCrowdfund.cshtml @@ -30,11 +30,11 @@
- @if (TempData.ContainsKey("TempDataProperty-StatusMessage")) + @if (TempData.HasStatusMessage()) {
- +
} diff --git a/BTCPayServer/Views/Apps/UpdatePointOfSale.cshtml b/BTCPayServer/Views/Apps/UpdatePointOfSale.cshtml index 49d40a5c4..bdb1c9900 100644 --- a/BTCPayServer/Views/Apps/UpdatePointOfSale.cshtml +++ b/BTCPayServer/Views/Apps/UpdatePointOfSale.cshtml @@ -30,11 +30,11 @@
- @if (TempData.ContainsKey("TempDataProperty-StatusMessage")) + @if (TempData.HasStatusMessage()) {
- +
} diff --git a/BTCPayServer/Views/Invoice/Invoice.cshtml b/BTCPayServer/Views/Invoice/Invoice.cshtml index 392dd5bfa..099b21692 100644 --- a/BTCPayServer/Views/Invoice/Invoice.cshtml +++ b/BTCPayServer/Views/Invoice/Invoice.cshtml @@ -17,11 +17,11 @@
- @if (!string.IsNullOrEmpty(Model.StatusMessage)) + @if (TempData.HasStatusMessage()) {
- +
} diff --git a/BTCPayServer/Views/Invoice/ListInvoices.cshtml b/BTCPayServer/Views/Invoice/ListInvoices.cshtml index 6ef06291a..daabddd24 100644 --- a/BTCPayServer/Views/Invoice/ListInvoices.cshtml +++ b/BTCPayServer/Views/Invoice/ListInvoices.cshtml @@ -8,11 +8,11 @@ @Html.HiddenFor(a => a.Count)
- @if (!string.IsNullOrEmpty(Model.StatusMessage)) + @if (TempData.HasStatusMessage()) {
- +
} diff --git a/BTCPayServer/Views/Manage/ChangePassword.cshtml b/BTCPayServer/Views/Manage/ChangePassword.cshtml index 8788380b7..4628e035c 100644 --- a/BTCPayServer/Views/Manage/ChangePassword.cshtml +++ b/BTCPayServer/Views/Manage/ChangePassword.cshtml @@ -3,7 +3,7 @@ ViewData.SetActivePageAndTitle(ManageNavPages.ChangePassword, "Change password"); } - +
diff --git a/BTCPayServer/Views/Manage/ExternalLogins.cshtml b/BTCPayServer/Views/Manage/ExternalLogins.cshtml deleted file mode 100644 index c1ec86ddc..000000000 --- a/BTCPayServer/Views/Manage/ExternalLogins.cshtml +++ /dev/null @@ -1,51 +0,0 @@ -@model ExternalLoginsViewModel -@{ - ViewData.SetActivePageAndTitle(ManageNavPages.ExternalLogins, "Manage your external logins"); -} - - -@if (Model.CurrentLogins?.Count > 0) -{ -

Registered Logins

- - - @foreach (var login in Model.CurrentLogins) - { - - - - - } - -
@login.LoginProvider - @if (Model.ShowRemoveButton) - { - -
- - - -
- - } - else - { - @:   - } -
-} -@if (Model.OtherLogins?.Count > 0) -{ -

Add another service to log in.

-
-
-
-

- @foreach (var provider in Model.OtherLogins) - { - - } -

-
-
-} diff --git a/BTCPayServer/Views/Manage/Index.cshtml b/BTCPayServer/Views/Manage/Index.cshtml index 37d2bf92b..eb0a258f5 100644 --- a/BTCPayServer/Views/Manage/Index.cshtml +++ b/BTCPayServer/Views/Manage/Index.cshtml @@ -3,7 +3,8 @@ ViewData.SetActivePageAndTitle(ManageNavPages.Index, "Profile"); } - + +
diff --git a/BTCPayServer/Views/Manage/ManageNavPages.cs b/BTCPayServer/Views/Manage/ManageNavPages.cs index 4c2b9370f..6227b33d7 100644 --- a/BTCPayServer/Views/Manage/ManageNavPages.cs +++ b/BTCPayServer/Views/Manage/ManageNavPages.cs @@ -7,6 +7,6 @@ namespace BTCPayServer.Views.Manage { public enum ManageNavPages { - Index, ChangePassword, ExternalLogins, TwoFactorAuthentication, U2F + Index, ChangePassword, TwoFactorAuthentication, U2F } } diff --git a/BTCPayServer/Views/Manage/SetPassword.cshtml b/BTCPayServer/Views/Manage/SetPassword.cshtml index a53bd7961..940a0b1c4 100644 --- a/BTCPayServer/Views/Manage/SetPassword.cshtml +++ b/BTCPayServer/Views/Manage/SetPassword.cshtml @@ -4,7 +4,7 @@ }

Set your password

- +

You do not have a local username/password for this site. Add a local account so you can log in without an external login. diff --git a/BTCPayServer/Views/Manage/U2FAuthentication.cshtml b/BTCPayServer/Views/Manage/U2FAuthentication.cshtml index dab81d2fb..674802f15 100644 --- a/BTCPayServer/Views/Manage/U2FAuthentication.cshtml +++ b/BTCPayServer/Views/Manage/U2FAuthentication.cshtml @@ -3,7 +3,7 @@ ViewData.SetActivePageAndTitle(ManageNavPages.U2F, "Manage your registered U2F devices"); } - +

Registered U2F Devices

diff --git a/BTCPayServer/Views/Manage/_Nav.cshtml b/BTCPayServer/Views/Manage/_Nav.cshtml index d15f81769..7c27d57cf 100644 --- a/BTCPayServer/Views/Manage/_Nav.cshtml +++ b/BTCPayServer/Views/Manage/_Nav.cshtml @@ -1,15 +1,8 @@ @inject SignInManager SignInManager -@{ - var hasExternalLogins = (await SignInManager.GetExternalAuthenticationSchemesAsync()).Any(); -} diff --git a/BTCPayServer/Views/MoneroLikeStore/GetStoreMoneroLikePaymentMethod.cshtml b/BTCPayServer/Views/MoneroLikeStore/GetStoreMoneroLikePaymentMethod.cshtml index 87d7730d9..6f4dfb8ae 100644 --- a/BTCPayServer/Views/MoneroLikeStore/GetStoreMoneroLikePaymentMethod.cshtml +++ b/BTCPayServer/Views/MoneroLikeStore/GetStoreMoneroLikePaymentMethod.cshtml @@ -10,7 +10,7 @@ } - +
diff --git a/BTCPayServer/Views/MoneroLikeStore/GetStoreMoneroLikePaymentMethods.cshtml b/BTCPayServer/Views/MoneroLikeStore/GetStoreMoneroLikePaymentMethods.cshtml index a1c70b844..00e94aa09 100644 --- a/BTCPayServer/Views/MoneroLikeStore/GetStoreMoneroLikePaymentMethods.cshtml +++ b/BTCPayServer/Views/MoneroLikeStore/GetStoreMoneroLikePaymentMethods.cshtml @@ -10,7 +10,7 @@ } - +
diff --git a/BTCPayServer/Views/PaymentRequest/EditPaymentRequest.cshtml b/BTCPayServer/Views/PaymentRequest/EditPaymentRequest.cshtml index 7b68786bc..1bfe0ccd2 100644 --- a/BTCPayServer/Views/PaymentRequest/EditPaymentRequest.cshtml +++ b/BTCPayServer/Views/PaymentRequest/EditPaymentRequest.cshtml @@ -10,11 +10,11 @@
- @if (!string.IsNullOrEmpty(Model.StatusMessage)) + @if (TempData.HasStatusMessage()) {
- +
} diff --git a/BTCPayServer/Views/PaymentRequest/GetPaymentRequests.cshtml b/BTCPayServer/Views/PaymentRequest/GetPaymentRequests.cshtml index 921f06b18..50874a7d5 100644 --- a/BTCPayServer/Views/PaymentRequest/GetPaymentRequests.cshtml +++ b/BTCPayServer/Views/PaymentRequest/GetPaymentRequests.cshtml @@ -5,11 +5,11 @@ }
- @if (!string.IsNullOrEmpty(Model.StatusMessage)) + @if (TempData.HasStatusMessage()) {
- +
} diff --git a/BTCPayServer/Views/PaymentRequest/ViewPaymentRequest.cshtml b/BTCPayServer/Views/PaymentRequest/ViewPaymentRequest.cshtml index 1f066d8cd..cc201628c 100644 --- a/BTCPayServer/Views/PaymentRequest/ViewPaymentRequest.cshtml +++ b/BTCPayServer/Views/PaymentRequest/ViewPaymentRequest.cshtml @@ -36,7 +36,7 @@ - + @if (Context.Request.Query.ContainsKey("simple")) { @await Html.PartialAsync("MinimalPaymentRequest", Model) diff --git a/BTCPayServer/Views/Server/ListUsers.cshtml b/BTCPayServer/Views/Server/ListUsers.cshtml index ab24e4a25..6dbd8df40 100644 --- a/BTCPayServer/Views/Server/ListUsers.cshtml +++ b/BTCPayServer/Views/Server/ListUsers.cshtml @@ -3,7 +3,7 @@ ViewData.SetActivePageAndTitle(ServerNavPages.Users); } - +
Total Users: @Model.Total
diff --git a/BTCPayServer/Views/Server/Logs.cshtml b/BTCPayServer/Views/Server/Logs.cshtml index be1439715..9df0a193a 100644 --- a/BTCPayServer/Views/Server/Logs.cshtml +++ b/BTCPayServer/Views/Server/Logs.cshtml @@ -3,7 +3,7 @@ ViewData.SetActivePageAndTitle(ServerNavPages.Logs); } - +
    diff --git a/BTCPayServer/Views/Server/User.cshtml b/BTCPayServer/Views/Server/User.cshtml index 341d93170..67da9dfce 100644 --- a/BTCPayServer/Views/Server/User.cshtml +++ b/BTCPayServer/Views/Server/User.cshtml @@ -5,7 +5,7 @@

    Modify User - @Model.Email

    - +
    diff --git a/BTCPayServer/Views/Shared/EmailsBody.cshtml b/BTCPayServer/Views/Shared/EmailsBody.cshtml index 25d538474..a44b349f3 100644 --- a/BTCPayServer/Views/Shared/EmailsBody.cshtml +++ b/BTCPayServer/Views/Shared/EmailsBody.cshtml @@ -1,7 +1,7 @@ @model BTCPayServer.Models.ServerViewModels.EmailsViewModel - +
    diff --git a/BTCPayServer/Views/Shared/_StatusMessage.cshtml b/BTCPayServer/Views/Shared/_StatusMessage.cshtml index 00e73787e..ab47f4d7b 100644 --- a/BTCPayServer/Views/Shared/_StatusMessage.cshtml +++ b/BTCPayServer/Views/Shared/_StatusMessage.cshtml @@ -1,8 +1,29 @@ -@model string +@{ + StatusMessageModel parsedModel = null; + TempData.TryGetValue(WellKnownTempData.SuccessMessage, out var successMessage); + TempData.TryGetValue(WellKnownTempData.ErrorMessage, out var errorMessage); + TempData.TryGetValue(WellKnownTempData.StatusMessageModel, out var model); + if (successMessage != null || errorMessage != null) + { + parsedModel = new StatusMessageModel(); + parsedModel.Message = (string)successMessage ?? (string)errorMessage; + if (successMessage != null) + { + parsedModel.Severity = StatusMessageModel.StatusSeverity.Success; + } + else + { + parsedModel.Severity = StatusMessageModel.StatusSeverity.Error; + } + } + else if (model != null) + { + parsedModel = model as StatusMessageModel; + } +} -@if (!string.IsNullOrEmpty(Model)) +@if (parsedModel != null) { - var parsedModel = new StatusMessageModel(Model);