mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Add IsRoleAdmin to user service
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user