mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 14:22:40 +01:00
Can lock down registrations
This commit is contained in:
parent
c263016939
commit
45aee607e3
4 changed files with 16 additions and 3 deletions
|
@ -2,7 +2,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||||
<Version>1.0.0.35</Version>
|
<Version>1.0.0.36</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="Build\dockerfiles\**" />
|
<Compile Remove="Build\dockerfiles\**" />
|
||||||
|
|
|
@ -235,8 +235,11 @@ namespace BTCPayServer.Controllers
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public IActionResult Register(string returnUrl = null)
|
public async Task<IActionResult> Register(string returnUrl = null)
|
||||||
{
|
{
|
||||||
|
var policies = await _SettingsRepository.GetSettingAsync<PoliciesSettings>() ?? new PoliciesSettings();
|
||||||
|
if (policies.LockSubscription)
|
||||||
|
return RedirectToAction(nameof(HomeController.Index), "Home");
|
||||||
ViewData["ReturnUrl"] = returnUrl;
|
ViewData["ReturnUrl"] = returnUrl;
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
@ -247,9 +250,11 @@ namespace BTCPayServer.Controllers
|
||||||
public async Task<IActionResult> Register(RegisterViewModel model, string returnUrl = null)
|
public async Task<IActionResult> Register(RegisterViewModel model, string returnUrl = null)
|
||||||
{
|
{
|
||||||
ViewData["ReturnUrl"] = returnUrl;
|
ViewData["ReturnUrl"] = returnUrl;
|
||||||
|
var policies = await _SettingsRepository.GetSettingAsync<PoliciesSettings>() ?? new PoliciesSettings();
|
||||||
|
if (policies.LockSubscription)
|
||||||
|
return RedirectToAction(nameof(HomeController.Index), "Home");
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
var policies = await _SettingsRepository.GetSettingAsync<PoliciesSettings>() ?? new PoliciesSettings();
|
|
||||||
var user = new ApplicationUser { UserName = model.Email, Email = model.Email, RequiresEmailConfirmation = policies.RequiresConfirmedEmail };
|
var user = new ApplicationUser { UserName = model.Email, Email = model.Email, RequiresEmailConfirmation = policies.RequiresConfirmedEmail };
|
||||||
var result = await _userManager.CreateAsync(user, model.Password);
|
var result = await _userManager.CreateAsync(user, model.Password);
|
||||||
if (result.Succeeded)
|
if (result.Succeeded)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace BTCPayServer.Services
|
namespace BTCPayServer.Services
|
||||||
{
|
{
|
||||||
|
@ -11,5 +12,8 @@ namespace BTCPayServer.Services
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
||||||
|
public bool LockSubscription { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
<label asp-for="RequiresConfirmedEmail"></label>
|
<label asp-for="RequiresConfirmedEmail"></label>
|
||||||
<input asp-for="RequiresConfirmedEmail" type="checkbox" class="form-check-inline" />
|
<input asp-for="RequiresConfirmedEmail" type="checkbox" class="form-check-inline" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label asp-for="LockSubscription"></label>
|
||||||
|
<input asp-for="LockSubscription" type="checkbox" class="form-check-inline" />
|
||||||
|
</div>
|
||||||
<button type="submit" class="btn btn-success" name="command" value="Save">Save</button>
|
<button type="submit" class="btn btn-success" name="command" value="Save">Save</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue