export enum AuthType { INTERNAL = 1, CLIENT = 2, } export enum EWorkSpaceType { NEXTA = 1, SCHOOL = 2, INDIVIDUAL = 3, } export class AuthContext { userId: string; authorities: string[]; workspaceId: string; workspaceType: EWorkSpaceType; authType?: AuthType; constructor(userId: string, workspaceId: string, workspaceType: string, authorities: string, authType?: AuthType) { this.userId = userId; this.workspaceId = workspaceId; this.workspaceType = workspaceType ? parseInt(workspaceType) : 0; this.authorities = authorities ? authorities?.split(',').map((s) => s.trim()) : []; this.authType = authType; } hasAuthority(authority: any): boolean { if (this.authType === AuthType.INTERNAL) { return true; } return this.authorities.some((x) => x === authority); } }