From 6a1da0879a4d0dda3765b19c8bbbe0de1bded044 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Wed, 27 Nov 2024 20:38:52 -0800 Subject: [PATCH] reduce calls --- .../OrchardCore.Roles/Services/RoleClaimsProvider.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Services/RoleClaimsProvider.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Services/RoleClaimsProvider.cs index 0b767270ffd..5e423fef13b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Services/RoleClaimsProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Services/RoleClaimsProvider.cs @@ -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));