Only checking for last admin if user being deleted is admin

Bugfixing issue #632
This commit is contained in:
rockstardev
2019-03-02 20:01:32 -06:00
committed by Rockstar Developer
parent 420115c54d
commit fee936b569

View File

@@ -384,6 +384,9 @@ namespace BTCPayServer.Controllers
if (user == null) if (user == null)
return NotFound(); return NotFound();
var roles = await _UserManager.GetRolesAsync(user);
if (IsAdmin(roles))
{
var admins = await _UserManager.GetUsersInRoleAsync(Roles.ServerAdmin); var admins = await _UserManager.GetUsersInRoleAsync(Roles.ServerAdmin);
if (admins.Count == 1) if (admins.Count == 1)
{ {
@@ -392,10 +395,6 @@ namespace BTCPayServer.Controllers
"This is the last Admin, so it can't be removed")); "This is the last Admin, so it can't be removed"));
} }
var roles = await _UserManager.GetRolesAsync(user);
if (IsAdmin(roles))
{
return View("Confirm", new ConfirmModel("Delete Admin " + user.Email, return View("Confirm", new ConfirmModel("Delete Admin " + user.Email,
"Are you sure you want to delete this Admin and delete all accounts, users and data associated with the server account?", "Are you sure you want to delete this Admin and delete all accounts, users and data associated with the server account?",
"Delete")); "Delete"));