Several fixes
- added organizations - added industries - added logo in 2 colors for light and dark theme - improved authorization to allow multi tenancy
This commit is contained in:
19
src/app/pipes/is-role-allowed-pipe.ts
Normal file
19
src/app/pipes/is-role-allowed-pipe.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import Keycloak from 'keycloak-js';
|
||||
|
||||
@Pipe({
|
||||
name: 'isRoleAllowed',
|
||||
standalone: true
|
||||
})
|
||||
export class IsRoleAllowedPipe implements PipeTransform {
|
||||
constructor(private keycloak: Keycloak) {}
|
||||
|
||||
transform(allowed: string | string[], mode: 'any' | 'all' = 'any'): boolean {
|
||||
const userRoles = this.keycloak.realmAccess?.roles ?? [];
|
||||
const allowedRoles = Array.isArray(allowed) ? allowed : [allowed];
|
||||
|
||||
if (!allowedRoles.length) return true;
|
||||
if (mode === 'all') return allowedRoles.every(r => userRoles.includes(r));
|
||||
return allowedRoles.some(r => userRoles.includes(r));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user