Introduce cheat mode (#2965)

This commit is contained in:
Nicolas Dorier
2021-10-11 12:32:09 +09:00
committed by GitHub
parent e842a00402
commit d7a7382d00
14 changed files with 111 additions and 54 deletions

View File

@@ -411,7 +411,6 @@ namespace BTCPayServer.Controllers
if (policies.LockSubscription && !User.IsInRole(Roles.ServerAdmin))
return RedirectToAction(nameof(HomeController.Index), "Home");
ViewData["ReturnUrl"] = returnUrl;
ViewData["AllowIsAdmin"] = _Options.AllowAdminRegistration;
return View();
}
@@ -429,7 +428,6 @@ namespace BTCPayServer.Controllers
ViewData["ReturnUrl"] = returnUrl;
ViewData["Logon"] = logon.ToString(CultureInfo.InvariantCulture).ToLowerInvariant();
ViewData["AllowIsAdmin"] = _Options.AllowAdminRegistration;
var policies = await _SettingsRepository.GetSettingAsync<PoliciesSettings>() ?? new PoliciesSettings();
if (policies.LockSubscription && !User.IsInRole(Roles.ServerAdmin))
return RedirectToAction(nameof(HomeController.Index), "Home");
@@ -441,7 +439,7 @@ namespace BTCPayServer.Controllers
if (result.Succeeded)
{
var admin = await _userManager.GetUsersInRoleAsync(Roles.ServerAdmin);
if (admin.Count == 0 || (model.IsAdmin && _Options.AllowAdminRegistration))
if (admin.Count == 0 || (model.IsAdmin && _Options.CheatMode))
{
await _RoleManager.CreateAsync(new IdentityRole(Roles.ServerAdmin));
await _userManager.AddToRoleAsync(user, Roles.ServerAdmin);