diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index ceefea90b..d68e39ef7 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -2,7 +2,7 @@ Exe netcoreapp2.0 - 1.0.0.35 + 1.0.0.36 diff --git a/BTCPayServer/Controllers/AccountController.cs b/BTCPayServer/Controllers/AccountController.cs index 55237399d..3c2811245 100644 --- a/BTCPayServer/Controllers/AccountController.cs +++ b/BTCPayServer/Controllers/AccountController.cs @@ -235,8 +235,11 @@ namespace BTCPayServer.Controllers [HttpGet] [AllowAnonymous] - public IActionResult Register(string returnUrl = null) + public async Task Register(string returnUrl = null) { + var policies = await _SettingsRepository.GetSettingAsync() ?? new PoliciesSettings(); + if (policies.LockSubscription) + return RedirectToAction(nameof(HomeController.Index), "Home"); ViewData["ReturnUrl"] = returnUrl; return View(); } @@ -247,9 +250,11 @@ namespace BTCPayServer.Controllers public async Task Register(RegisterViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; + var policies = await _SettingsRepository.GetSettingAsync() ?? new PoliciesSettings(); + if (policies.LockSubscription) + return RedirectToAction(nameof(HomeController.Index), "Home"); if (ModelState.IsValid) { - var policies = await _SettingsRepository.GetSettingAsync() ?? new PoliciesSettings(); var user = new ApplicationUser { UserName = model.Email, Email = model.Email, RequiresEmailConfirmation = policies.RequiresConfirmedEmail }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) diff --git a/BTCPayServer/Services/PoliciesSettings.cs b/BTCPayServer/Services/PoliciesSettings.cs index abbaf406d..431e902eb 100644 --- a/BTCPayServer/Services/PoliciesSettings.cs +++ b/BTCPayServer/Services/PoliciesSettings.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Newtonsoft.Json; namespace BTCPayServer.Services { @@ -11,5 +12,8 @@ namespace BTCPayServer.Services { get; set; } + + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] + public bool LockSubscription { get; set; } } } diff --git a/BTCPayServer/Views/Server/Policies.cshtml b/BTCPayServer/Views/Server/Policies.cshtml index 83a636ec3..f744ac4dc 100644 --- a/BTCPayServer/Views/Server/Policies.cshtml +++ b/BTCPayServer/Views/Server/Policies.cshtml @@ -19,6 +19,10 @@ +
+ + +