Skip to content

Commit

Permalink
reduce calls
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek committed Nov 28, 2024
1 parent d6f1abb commit 6a1da08
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,19 @@ public async Task GenerateAsync(IUser user, ClaimsIdentity claims)
return;
}

var isAdministrator = await _userManager.IsInRoleAsync(user, await _systemRoleNameProvider.GetAdminRoleAsync());
var isAdministrator = false;

var roleNames = await _userManager.GetRolesAsync(user);

foreach (var roleName in roleNames)
{
if (await _systemRoleNameProvider.IsAdminRoleAsync(roleName))
{
isAdministrator = true;
break;
}
}

foreach (var roleName in roleNames)
{
claims.AddClaim(new Claim(_identityOptions.ClaimsIdentity.RoleClaimType, roleName));
Expand Down

0 comments on commit 6a1da08

Please sign in to comment.