SUPPORT-8956: check role?
This commit is contained in:
parent
6301122e84
commit
1a97931705
2 changed files with 21 additions and 0 deletions
17
frontend/src/ts/account_applications/ErvuCheckUserRole.ts
Normal file
17
frontend/src/ts/account_applications/ErvuCheckUserRole.ts
Normal file
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue