Refactor StatusMessage and remove ExternalLogin

This commit is contained in:
nicolas.dorier 2019-10-31 12:29:59 +09:00
parent 99095f25d9
commit aad586232c
No known key found for this signature in database
GPG key ID: 6618763EF09186FE
75 changed files with 185 additions and 516 deletions

View file

@ -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))

View file

@ -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
{

View file

@ -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();
}

View file

@ -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<ViewResult>(testResult).Model).StatusMessage, StringComparison.OrdinalIgnoreCase);
Assert.False(storeController.TempData.ContainsKey(WellKnownTempData.ErrorMessage));
storeController.TempData.Clear();
Assert.True(storeController.ModelState.IsValid);
Assert.IsType<RedirectToActionResult>(storeController.AddLightningNode(user.StoreId, new LightningNodeViewModel()
@ -746,7 +747,7 @@ namespace BTCPayServer.Tests
acc.CreateStore();
var store2 = acc.GetController<StoresController>();
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);
}
}

View file

@ -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));

View file

@ -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<IActionResult> 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<IActionResult> 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<IActionResult> ConfirmEmail(string userId, string code)

View file

@ -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});
}
}

View file

@ -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 });
}

View file

@ -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<IActionResult> 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. <a href='{(Url.Action("CreateStore", "UserStores"))}'>Create store</a>",
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. <a href='{(Url.Action("CreateStore", "UserStores"))}'>Create store</a>",
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)

View file

@ -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);

View file

@ -11,9 +11,9 @@ namespace BTCPayServer.Controllers
[HttpGet]
public async Task<IActionResult> U2FAuthentication(string statusMessage = null)
{
TempData[WellKnownTempData.SuccessMessage] = statusMessage;
return View(new U2FAuthenticationViewModel()
{
StatusMessage = statusMessage,
Devices = await _u2FService.GetDevices(_userManager.GetUserId(User))
});
}

View file

@ -64,12 +64,6 @@ namespace BTCPayServer.Controllers
_StoreRepository = storeRepository;
}
[TempData]
public string StatusMessage
{
get; set;
}
[HttpGet]
public async Task<IActionResult> 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<IActionResult> 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<IActionResult> 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<IActionResult> 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<IActionResult> 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

View file

@ -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);
}

View file

@ -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);

View file

@ -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));

View file

@ -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:

View file

@ -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});

View file

@ -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});

View file

@ -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);

View file

@ -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<IActionResult> 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<IActionResult> 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

View file

@ -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<IActionResult> 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

View file

@ -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);
}
}

View file

@ -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));
}
}

View file

@ -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));

View file

@ -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; }
}
}

View file

@ -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; }

View file

@ -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;

View file

@ -15,7 +15,6 @@ namespace BTCPayServer.Models.InvoicingModels
public int? TimezoneOffset { get; set; }
public List<InvoiceModel> Invoices { get; set; } = new List<InvoiceModel>();
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; }
}

View file

@ -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; }
}
}

View file

@ -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<UserLoginInfo> CurrentLogins { get; set; }
public IList<AuthenticationScheme> OtherLogins { get; set; }
public bool ShowRemoveButton { get; set; }
public string StatusMessage { get; set; }
}
}

View file

@ -27,10 +27,5 @@ namespace BTCPayServer.Models.ManageViewModels
[MaxLength(50)]
public string PhoneNumber { get; set; }
public string StatusMessage
{
get; set;
}
}
}

View file

@ -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; }
}
}

View file

@ -15,7 +15,6 @@ namespace BTCPayServer.Models.PaymentRequestViewModels
public List<ViewPaymentRequestViewModel> 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
{

View file

@ -10,10 +10,6 @@ namespace BTCPayServer.Models.ServerViewModels
{
public class EmailsViewModel
{
public string StatusMessage
{
get; set;
}
public EmailSettings Settings
{
get; set;

View file

@ -5,12 +5,6 @@ namespace BTCPayServer.Models.ServerViewModels
{
public class LogsViewModel
{
public string StatusMessage
{
get; set;
}
public List<FileInfo> LogFiles { get; set; } = new List<FileInfo>();
public string Log { get; set; }
public int LogFileCount { get; set; }

View file

@ -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; }
}
}

View file

@ -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<UserViewModel> Users { get; set; } = new List<UserViewModel>();
}

View file

@ -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")]

View file

@ -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;

View file

@ -53,11 +53,6 @@ namespace BTCPayServer.Models.StoreViewModels
{
get; set;
}
public string StatusMessage
{
get;
set;
}
[Display(Name = "API Key")]
public string ApiKey { get; set; }

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -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/"
}

View file

@ -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<MoneroSupportedPaymentMethod>(), 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<MoneroLikePaymentMethodViewModel> 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; }

View file

@ -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,

View file

@ -5,7 +5,6 @@ namespace BTCPayServer.U2F.Models
{
public class U2FAuthenticationViewModel
{
public string StatusMessage { get; set; }
public List<U2FDevice> Devices { get; set; }
}
}

View file

@ -1,32 +0,0 @@
@model ExternalLoginViewModel
@{
ViewData["Title"] = "Register";
}
<h2>@ViewData["Title"]</h2>
<h4>Associate your @ViewData["LoginProvider"] account.</h4>
<hr />
<p class="text-info">
You've successfully authenticated with <strong>@ViewData["LoginProvider"]</strong>.
Please enter an email address for this site below and click the Register button to finish
logging in.
</p>
<div class="row">
<div class="col-md-4">
<form asp-action="ExternalLoginConfirmation" asp-route-returnurl="@ViewData["ReturnUrl"]" method="post">
<div asp-validation-summary="All" class="text-danger"></div>
<div class="form-group">
<label asp-for="Email"></label>
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
<button type="submit" class="btn btn-primary">Register</button>
</form>
</div>
</div>
@section Scripts {
@await Html.PartialAsync("_ValidationScriptsPartial")
}

View file

@ -5,11 +5,11 @@
}
<section>
<div class="container">
@if (TempData.ContainsKey("TempDataProperty-StatusMessage"))
@if (TempData.HasStatusMessage())
{
<div class="row">
<div class="col-lg-12 text-center">
<partial name="_StatusMessage" for="@TempData["TempDataProperty-StatusMessage"]" />
<partial name="_StatusMessage" />
</div>
</div>
}

View file

@ -30,11 +30,11 @@
<hr class="primary">
</div>
</div>
@if (TempData.ContainsKey("TempDataProperty-StatusMessage"))
@if (TempData.HasStatusMessage())
{
<div class="row">
<div class="col-lg-12 text-center">
<partial name="_StatusMessage" for="@TempData["TempDataProperty-StatusMessage"]" />
<partial name="_StatusMessage" />
</div>
</div>
}

View file

@ -30,11 +30,11 @@
<hr class="primary">
</div>
</div>
@if (TempData.ContainsKey("TempDataProperty-StatusMessage"))
@if (TempData.HasStatusMessage())
{
<div class="row">
<div class="col-lg-12 text-center">
<partial name="_StatusMessage" for="@TempData["TempDataProperty-StatusMessage"]" />
<partial name="_StatusMessage" />
</div>
</div>
}

View file

@ -17,11 +17,11 @@
</style>
<section class="invoice-details">
<div class="container">
@if (!string.IsNullOrEmpty(Model.StatusMessage))
@if (TempData.HasStatusMessage())
{
<div class="row">
<div class="col-lg-12 text-center">
<partial name="_StatusMessage" for="StatusMessage" />
<partial name="_StatusMessage" />
</div>
</div>
}

View file

@ -8,11 +8,11 @@
@Html.HiddenFor(a => a.Count)
<section>
<div class="container">
@if (!string.IsNullOrEmpty(Model.StatusMessage))
@if (TempData.HasStatusMessage())
{
<div class="row">
<div class="col-lg-12 text-center">
<partial name="_StatusMessage" for="StatusMessage" />
<partial name="_StatusMessage" />
</div>
</div>
}

View file

@ -3,7 +3,7 @@
ViewData.SetActivePageAndTitle(ManageNavPages.ChangePassword, "Change password");
}
<partial name="_StatusMessage" for="StatusMessage" />
<partial name="_StatusMessage" />
<div class="row">
<div class="col-md-6">
<form method="post">

View file

@ -1,51 +0,0 @@
@model ExternalLoginsViewModel
@{
ViewData.SetActivePageAndTitle(ManageNavPages.ExternalLogins, "Manage your external logins");
}
<partial name="_StatusMessage" for="StatusMessage" />
@if (Model.CurrentLogins?.Count > 0)
{
<h4>Registered Logins</h4>
<table class="table table-sm table-responsive-md">
<tbody>
@foreach (var login in Model.CurrentLogins)
{
<tr>
<td>@login.LoginProvider</td>
<td>
@if (Model.ShowRemoveButton)
{
<form asp-action="RemoveLogin" method="post">
<div>
<input asp-for="@login.LoginProvider" name="LoginProvider" type="hidden" />
<input asp-for="@login.ProviderKey" name="ProviderKey" type="hidden" />
<button type="submit" class="btn btn-primary" title="Remove this @login.LoginProvider login from your account">Remove</button>
</div>
</form>
}
else
{
@: &nbsp;
}
</td>
</tr>
}
</tbody>
</table>
}
@if (Model.OtherLogins?.Count > 0)
{
<h4>Add another service to log in.</h4>
<hr />
<form asp-action="LinkLogin" method="post" class="form-horizontal">
<div id="socialLoginList">
<p>
@foreach (var provider in Model.OtherLogins)
{
<button type="submit" class="btn btn-primary" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
}
</p>
</div>
</form>
}

View file

@ -3,7 +3,8 @@
ViewData.SetActivePageAndTitle(ManageNavPages.Index, "Profile");
}
<partial name="_StatusMessage" for="StatusMessage" />
<partial name="_StatusMessage" />
<div class="row">
<div class="col-md-6">

View file

@ -7,6 +7,6 @@ namespace BTCPayServer.Views.Manage
{
public enum ManageNavPages
{
Index, ChangePassword, ExternalLogins, TwoFactorAuthentication, U2F
Index, ChangePassword, TwoFactorAuthentication, U2F
}
}

View file

@ -4,7 +4,7 @@
}
<h4>Set your password</h4>
<partial name="_StatusMessage" for="StatusMessage" />
<partial name="_StatusMessage" />
<p class="text-info">
You do not have a local username/password for this site. Add a local
account so you can log in without an external login.

View file

@ -3,7 +3,7 @@
ViewData.SetActivePageAndTitle(ManageNavPages.U2F, "Manage your registered U2F devices");
}
<partial name="_StatusMessage" for="StatusMessage"/>
<partial name="_StatusMessage" />
<h4>Registered U2F Devices</h4>
<form asp-action="AddU2FDevice" method="get">
<table class="table table-lg">

View file

@ -1,15 +1,8 @@
@inject SignInManager<ApplicationUser> SignInManager
@{
var hasExternalLogins = (await SignInManager.GetExternalAuthenticationSchemesAsync()).Any();
}
<div class="nav flex-column nav-pills">
<a class="nav-link @ViewData.IsActivePage(ManageNavPages.Index)" asp-action="Index">Profile</a>
<a class="nav-link @ViewData.IsActivePage(ManageNavPages.ChangePassword)" asp-action="ChangePassword" id="ChangePassword">Password</a>
@if (hasExternalLogins)
{
<a class="nav-link @ViewData.IsActivePage(ManageNavPages.ExternalLogins)" asp-action="ExternalLogins">External logins</a>
}
<a class="nav-link @ViewData.IsActivePage(ManageNavPages.TwoFactorAuthentication)" asp-action="TwoFactorAuthentication">Two-factor authentication</a>
<a class="nav-link @ViewData.IsActivePage(ManageNavPages.U2F)" asp-action="U2FAuthentication">U2F Authentication</a>
</div>

View file

@ -10,7 +10,7 @@
}
<partial name="_StatusMessage" for="StatusMessage"/>
<partial name="_StatusMessage" />
<div class="row">
<div class="col-md-6">

View file

@ -10,7 +10,7 @@
}
<partial name="_StatusMessage" for="StatusMessage" />
<partial name="_StatusMessage" />
<div class="row">
<div class="col-md-6">

View file

@ -10,11 +10,11 @@
<hr class="primary">
</div>
</div>
@if (!string.IsNullOrEmpty(Model.StatusMessage))
@if (TempData.HasStatusMessage())
{
<div class="row">
<div class="col-lg-12 text-center">
<partial name="_StatusMessage" for="StatusMessage" />
<partial name="_StatusMessage" />
</div>
</div>
}

View file

@ -5,11 +5,11 @@
}
<section>
<div class="container">
@if (!string.IsNullOrEmpty(Model.StatusMessage))
@if (TempData.HasStatusMessage())
{
<div class="row">
<div class="col-lg-12 text-center">
<partial name="_StatusMessage" for="StatusMessage" />
<partial name="_StatusMessage" />
</div>
</div>
}

View file

@ -36,7 +36,7 @@
</head>
<body>
<partial name="_StatusMessage" for="StatusMessage" />
<partial name="_StatusMessage" />
@if (Context.Request.Query.ContainsKey("simple"))
{
@await Html.PartialAsync("MinimalPaymentRequest", Model)

View file

@ -3,7 +3,7 @@
ViewData.SetActivePageAndTitle(ServerNavPages.Users);
}
<partial name="_StatusMessage" for="StatusMessage" />
<partial name="_StatusMessage" />
<div class="row">
<div class="col align-self-center">Total Users: @Model.Total</div>

View file

@ -3,7 +3,7 @@
ViewData.SetActivePageAndTitle(ServerNavPages.Logs);
}
<partial name="_StatusMessage" for="StatusMessage"/>
<partial name="_StatusMessage" />
<div class="row">
<ul>

View file

@ -5,7 +5,7 @@
<h4>Modify User - @Model.Email</h4>
<partial name="_StatusMessage" for="StatusMessage" />
<partial name="_StatusMessage" />
<div class="row">

View file

@ -1,7 +1,7 @@
@model BTCPayServer.Models.ServerViewModels.EmailsViewModel
<partial name="_StatusMessage" for="StatusMessage"/>
<partial name="_StatusMessage" />
<div class="row">
<div class="col-md-6">

View file

@ -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);
<div class="alert alert-@parsedModel.SeverityCSS @(parsedModel.AllowDismiss? "alert-dismissible":"" )" role="alert">
@if (parsedModel.AllowDismiss)
{

View file

@ -12,7 +12,7 @@
</style>
}
<partial name="_StatusMessage" for="StatusMessage" />
<partial name="_StatusMessage" />
<div class="row">
<div class="col-md-6">
<div asp-validation-summary="All" class="text-danger"></div>

View file

@ -4,7 +4,7 @@
ViewData.SetActivePageAndTitle(StoreNavPages.Index, "Add lightning node (Experimental)");
}
<partial name="_StatusMessage" for="StatusMessage" />
<partial name="_StatusMessage" />
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>

View file

@ -4,7 +4,7 @@
ViewData.SetActivePageAndTitle(StoreNavPages.Tokens, "Access Tokens");
}
<partial name="_StatusMessage" for="StatusMessage" />
<partial name="_StatusMessage" />
@if (Model.StoreNotConfigured)
{
<div class="alert alert-warning alert-dismissible" role="alert">

View file

@ -5,7 +5,7 @@
ViewData.SetActivePageAndTitle(StoreNavPages.Index, "Update Store Changelly Settings");
}
<partial name="_StatusMessage" for="StatusMessage"/>
<partial name="_StatusMessage" />
<div class="row">
<div class="col-md-10">

View file

@ -5,7 +5,7 @@
ViewData.SetActivePageAndTitle(StoreNavPages.Index, "Update Store CoinSwitch Settings");
}
<partial name="_StatusMessage" for="StatusMessage"/>
<partial name="_StatusMessage" />
<div class="row">
<div class="col-md-10">

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace BTCPayServer
{
public class WellKnownTempData
{
public const string SuccessMessage = nameof(SuccessMessage);
public const string ErrorMessage = nameof(ErrorMessage);
public const string StatusMessageModel = nameof(StatusMessageModel);
}
}