Replace admin check with CanModifyServerSettings authorization policy

This commit is contained in:
Umar Bolatov
2021-04-10 19:33:37 -07:00
parent 9fc2d2b76b
commit 949d6bf584

View File

@@ -197,15 +197,9 @@ namespace BTCPayServer.Controllers.GreenField
}
[HttpDelete("~/api/v1/users/{userId}")]
[Authorize(AuthenticationSchemes = AuthenticationSchemes.GreenfieldAPIKeys)]
[Authorize(Policy = Policies.CanModifyServerSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
public async Task<ActionResult<ApplicationUserData>> DeleteUser(string userId)
{
// Only admins should be allowed to delete users
if (!User.IsInRole(Roles.ServerAdmin))
{
return Forbid(AuthenticationSchemes.GreenfieldBasic);
}
var user = userId == null ? null : await _userManager.FindByIdAsync(userId);
if (user == null)
{