mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-23 14:40:36 +01:00
Refactoring if condition to ensure CanCreateUser permission
Fixing UsersControllerTests
This commit is contained in:
parent
47c1164003
commit
0a8abaf7d5
1 changed files with 4 additions and 4 deletions
|
@ -90,11 +90,11 @@ namespace BTCPayServer.Controllers.RestApi.Users
|
|||
return Forbid(AuthenticationSchemes.ApiKey);
|
||||
}
|
||||
|
||||
if (!isAdmin && policies.LockSubscription)
|
||||
// check if we have permission to create users
|
||||
var canCreateUser = (await _authorizationService.AuthorizeAsync(User, null, new PolicyRequirement(Policies.CanCreateUser.Key))).Succeeded;
|
||||
if (!canCreateUser)
|
||||
{
|
||||
// If we are not admin and subscriptions are locked, we need to check the Policies.CanCreateUser.Key permission
|
||||
if (!isAuth || !(await _authorizationService.AuthorizeAsync(User, null, new PolicyRequirement(Policies.CanCreateUser.Key))).Succeeded)
|
||||
return Forbid(AuthenticationSchemes.ApiKey);
|
||||
return Forbid(AuthenticationSchemes.ApiKey);
|
||||
}
|
||||
|
||||
var user = new ApplicationUser
|
||||
|
|
Loading…
Add table
Reference in a new issue