diff --git a/frontend/src/ts/account_applications/ErvuCheckUserRole.ts b/frontend/src/ts/account_applications/ErvuCheckUserRole.ts new file mode 100644 index 00000000..c5627e05 --- /dev/null +++ b/frontend/src/ts/account_applications/ErvuCheckUserRole.ts @@ -0,0 +1,17 @@ +import {AnalyticalScope, Behavior, Visible} from "@webbpm/base-package"; +import {AuthorizationService} from "../modules/app/service/authorization.service"; + +@AnalyticalScope(Behavior) +export class ErvuCheckUserRole extends Behavior{ + private authService: AuthorizationService; + + public initialize(): void { + super.initialize(); + this.authService = this.injector.get(AuthorizationService); + } + + @Visible() + public hasRole(role: string): boolean { + return this.authService.hasRole(role); + } +} diff --git a/frontend/src/ts/modules/app/service/authorization.service.ts b/frontend/src/ts/modules/app/service/authorization.service.ts index b346b465..8f1ad604 100644 --- a/frontend/src/ts/modules/app/service/authorization.service.ts +++ b/frontend/src/ts/modules/app/service/authorization.service.ts @@ -37,6 +37,10 @@ export class AuthorizationService { return this.isAuthorized() && roles.some(role => this.getRoles().includes(role)); } + hasRole(role: string): boolean { + return this.isAuthorized() && this.getRoles().includes(role); + } + getName(): string { return this.isAuthorized() ? this.session.name : null; }