Add IsRoleAdmin to user service

This commit is contained in:
Umar Bolatov
2021-03-14 13:02:43 -07:00
parent e5a196918f
commit 2ed8341403
3 changed files with 16 additions and 17 deletions

View File

@@ -198,7 +198,7 @@ namespace BTCPayServer.Controllers.GreenField
var roles = await _userManager.GetRolesAsync(user);
// We can safely delete the user if it's not an admin user
if (!IsAdmin(roles))
if (!_userService.IsRoleAdmin(roles))
{
await _userService.DeleteUserAndAssociatedData(user);
@@ -218,8 +218,6 @@ namespace BTCPayServer.Controllers.GreenField
return Ok();
}
private async Task<Boolean> IsAdmin()
{
var anyAdmin = (await _userManager.GetUsersInRoleAsync(Roles.ServerAdmin)).Any();
@@ -235,11 +233,6 @@ namespace BTCPayServer.Controllers.GreenField
&& isAuth;
}
private static bool IsAdmin(IList<string> roles)
{
return roles.Contains(Roles.ServerAdmin, StringComparer.Ordinal);
}
private async Task<ApplicationUserData> FromModel(ApplicationUser data)
{
var roles = (await _userManager.GetRolesAsync(data)).ToArray();