File tree Expand file tree Collapse file tree
application/CohortManager/src/Functions/Shared/Common/Authentication Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ namespace Common ;
2+
3+ public enum Role
4+ {
5+ CohortManagerUser ,
6+ CohortManagerDummyGpRemoval
7+ }
Original file line number Diff line number Diff line change 1+ namespace Common ;
2+
3+ using System . ComponentModel . DataAnnotations ;
4+
5+ public class RoleConfig
6+ {
7+ [ Required ]
8+ public required string CohortManagerUserWorkgroupId { get ; init ; }
9+ [ Required ]
10+ public required string CohortManagerDummyGpRemovalWorkgroupId { get ; init ; }
11+ }
Original file line number Diff line number Diff line change 1+ namespace Common ;
2+
3+ using Microsoft . Extensions . Options ;
4+
5+ public class RoleMapper
6+ {
7+ private readonly Dictionary < string , Role > _roleMappings ;
8+
9+ IOptions < RoleConfig > _roleConfig ;
10+ public RoleMapper ( IOptions < RoleConfig > roleConfig )
11+ {
12+ _roleConfig = roleConfig ;
13+ _roleMappings = new Dictionary < string , Role >
14+ {
15+ { _roleConfig . Value . CohortManagerUserWorkgroupId , Role . CohortManagerUser } ,
16+ { _roleConfig . Value . CohortManagerDummyGpRemovalWorkgroupId , Role . CohortManagerDummyGpRemoval }
17+ } ;
18+ }
19+
20+ public Role ? GetRole ( string workgroupId )
21+ {
22+ return _roleMappings . TryGetValue ( workgroupId , out var mappedRole ) ? mappedRole : null ;
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments