diff --git a/BTCPayServer/Controllers/AccountController.cs b/BTCPayServer/Controllers/AccountController.cs index 89ab09a8a..51e9c2156 100644 --- a/BTCPayServer/Controllers/AccountController.cs +++ b/BTCPayServer/Controllers/AccountController.cs @@ -17,6 +17,7 @@ using BTCPayServer.Services.Mails; using BTCPayServer.Services.Stores; using BTCPayServer.Logging; using BTCPayServer.Security; +using System.Globalization; namespace BTCPayServer.Controllers { @@ -236,23 +237,25 @@ namespace BTCPayServer.Controllers [HttpGet] [AllowAnonymous] - public async Task Register(string returnUrl = null) + public async Task Register(string returnUrl = null, bool logon = true) { var policies = await _SettingsRepository.GetSettingAsync() ?? new PoliciesSettings(); - if (policies.LockSubscription) + if (policies.LockSubscription && !User.IsInRole(Roles.ServerAdmin)) return RedirectToAction(nameof(HomeController.Index), "Home"); ViewData["ReturnUrl"] = returnUrl; + ViewData["Logon"] = logon.ToString(CultureInfo.InvariantCulture).ToLowerInvariant(); return View(); } [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] - public async Task Register(RegisterViewModel model, string returnUrl = null) + public async Task Register(RegisterViewModel model, string returnUrl = null, bool logon = true) { ViewData["ReturnUrl"] = returnUrl; + ViewData["Logon"] = logon.ToString(CultureInfo.InvariantCulture).ToLowerInvariant(); var policies = await _SettingsRepository.GetSettingAsync() ?? new PoliciesSettings(); - if (policies.LockSubscription) + if (policies.LockSubscription && !User.IsInRole(Roles.ServerAdmin)) return RedirectToAction(nameof(HomeController.Index), "Home"); if (ModelState.IsValid) { @@ -274,7 +277,8 @@ namespace BTCPayServer.Controllers await _emailSender.SendEmailConfirmationAsync(model.Email, callbackUrl); if (!policies.RequiresConfirmedEmail) { - await _signInManager.SignInAsync(user, isPersistent: false); + if(logon) + await _signInManager.SignInAsync(user, isPersistent: false); return RedirectToLocal(returnUrl); } else diff --git a/BTCPayServer/Extensions.cs b/BTCPayServer/Extensions.cs index f7a8f5e9b..0769b8379 100644 --- a/BTCPayServer/Extensions.cs +++ b/BTCPayServer/Extensions.cs @@ -137,6 +137,23 @@ namespace BTCPayServer request.PathBase.ToUriComponent()); } + public static string GetCurrentUrl(this HttpRequest request) + { + return string.Concat( + request.Scheme, + "://", + request.Host.ToUriComponent(), + request.PathBase.ToUriComponent(), + request.Path.ToUriComponent()); + } + + public static string GetCurrentPath(this HttpRequest request) + { + return string.Concat( + request.PathBase.ToUriComponent(), + request.Path.ToUriComponent()); + } + public static string GetAbsoluteUri(this HttpRequest request, string redirectUrl) { bool isRelative = diff --git a/BTCPayServer/Views/Account/Register.cshtml b/BTCPayServer/Views/Account/Register.cshtml index 129ac0d7d..0b2c4d939 100644 --- a/BTCPayServer/Views/Account/Register.cshtml +++ b/BTCPayServer/Views/Account/Register.cshtml @@ -16,7 +16,7 @@
-
+

Create a new account.


diff --git a/BTCPayServer/Views/Server/ListUsers.cshtml b/BTCPayServer/Views/Server/ListUsers.cshtml index 3f0a1619e..cded3b233 100644 --- a/BTCPayServer/Views/Server/ListUsers.cshtml +++ b/BTCPayServer/Views/Server/ListUsers.cshtml @@ -7,7 +7,7 @@

@ViewData["Title"]

- + Create a new user