@@ -80,26 +80,6 @@ export function isOrgSpecificRole(role: string): boolean {
8080 return role . startsWith ( ROLE_PREFIXES . ADMIN_FOR ) ;
8181}
8282
83- // TODO: remove it if we don't need it
84- /**
85- * Extract the location/org slug from a specific role
86- * @example extractRoleSlug('CityAdminFor:birmingham') => 'birmingham'
87- */
88- // export function extractRoleSlug(role: string): string | null {
89- // if (isLocationSpecificRole(role)) {
90- // if (role.startsWith(ROLE_PREFIXES.CITY_ADMIN_FOR)) {
91- // return role.substring(ROLE_PREFIXES.CITY_ADMIN_FOR.length);
92- // }
93- // if (role.startsWith(ROLE_PREFIXES.SWEP_ADMIN_FOR)) {
94- // return role.substring(ROLE_PREFIXES.SWEP_ADMIN_FOR.length);
95- // }
96- // }
97- // if (isOrgSpecificRole(role)) {
98- // return role.substring(ROLE_PREFIXES.ADMIN_FOR.length);
99- // }
100- // return null;
101- // }
102-
10383/**
10484 * Create a location-specific city admin role
10585 * @example createCityAdminRole('birmingham') => 'CityAdminFor:birmingham'
@@ -116,15 +96,6 @@ export function createSwepAdminRole(locationSlug: string): string {
11696 return `${ ROLE_PREFIXES . SWEP_ADMIN_FOR } ${ locationSlug } ` ;
11797}
11898
119- // TODO: remove it if we don't need it
120- /**
121- * Create an org-specific admin role
122- * @example createOrgAdminRole('org-slug') => 'AdminFor:org-slug'
123- */
124- // export function createOrgAdminRole(orgSlug: string): string {
125- // return `${ROLE_PREFIXES.ADMIN_FOR}${orgSlug}`;
126- // }
127-
12899/**
129100 * Validate if a role string matches the expected format
130101 */
@@ -144,30 +115,6 @@ export function isValidRole(role: string): boolean {
144115 return rolePatterns . some ( pattern => pattern . test ( role ) ) ;
145116}
146117
147- // TODO: remove it if we don't need it
148- /**
149- * Get all roles from a user's auth claims (base roles only)
150- */
151- // export function getBaseRoles(authClaims: string[]): BaseRole[] {
152- // return authClaims.filter(isBaseRole);
153- // }
154-
155- // TODO: remove it if we don't need it
156- /**
157- * Get all location-specific roles from auth claims
158- */
159- export function getLocationSpecificRoles ( authClaims : string [ ] ) : string [ ] {
160- return authClaims . filter ( isLocationSpecificRole ) ;
161- }
162-
163- // TODO: remove it if we don't need it
164- /**
165- * Get all org-specific roles from auth claims
166- */
167- // export function getOrgSpecificRoles(authClaims: string[]): string[] {
168- // return authClaims.filter(isOrgSpecificRole);
169- // }
170-
171118/**
172119 * Check if user has a specific base role
173120 */
@@ -203,27 +150,6 @@ export function hasLocationAccess(authClaims: string[], locationSlug: string): b
203150 return authClaims . includes ( cityAdminRole ) || authClaims . includes ( swepAdminRole ) ;
204151}
205152
206-
207- // TODO: remove it if we don't need it
208- /**
209- * Check if user has access to a specific organisation
210- */
211- // export function hasOrgAccess(authClaims: string[], orgSlug: string): boolean {
212- // // SuperAdmin has access to all organisations
213- // if (isSuperAdmin(authClaims)) {
214- // return true;
215- // }
216-
217- // // Check for general OrgAdmin role
218- // if (hasRole(authClaims, ROLES.ORG_ADMIN)) {
219- // return true;
220- // }
221-
222- // // Check for org-specific role
223- // const orgAdminRole = createOrgAdminRole(orgSlug);
224- // return authClaims.includes(orgAdminRole);
225- // }
226-
227153// ============================================================================
228154// VALIDATION REGEX
229155// ============================================================================
0 commit comments