diff --git a/Frontend/CO.CDP.OrganisationApp/Authorization/CustomScopeHandler.cs b/Frontend/CO.CDP.OrganisationApp/Authorization/CustomScopeHandler.cs index 972b31148..cfc1a726e 100644 --- a/Frontend/CO.CDP.OrganisationApp/Authorization/CustomScopeHandler.cs +++ b/Frontend/CO.CDP.OrganisationApp/Authorization/CustomScopeHandler.cs @@ -20,15 +20,6 @@ protected override async Task HandleRequirementAsync(AuthorizationHandlerContext { IUserInfoService _userInfo = serviceScope.ServiceProvider.GetRequiredService(); - var userScopes = await _userInfo.GetUserScopes(); - - // SupportAdmin role can do anything within any organisation - if (userScopes.Contains(PersonScopes.SupportAdmin)) - { - context.Succeed(requirement); - return; - } - var organisationUserScopes = await _userInfo.GetOrganisationUserScopes(); // Admin role can do anything within this organisation @@ -44,8 +35,11 @@ protected override async Task HandleRequirementAsync(AuthorizationHandlerContext return; } - // Editor role implies viewer permissions - if (requirement.Scope == OrganisationPersonScopes.Viewer && organisationUserScopes.Contains(OrganisationPersonScopes.Editor)) + var userScopes = await _userInfo.GetUserScopes(); + + // Editor role and support admin both imply viewer permissions + if (requirement.Scope == OrganisationPersonScopes.Viewer && + (organisationUserScopes.Contains(OrganisationPersonScopes.Editor) || userScopes.Contains(PersonScopes.SupportAdmin))) { context.Succeed(requirement); return;