mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-20 03:48:47 +00:00
* fix iam member model * fix org member model * fix auth user loading * copytoclipboard directive * directive logs, load bar on init, create user * typo * welcome section, contributor spinner * fix home link * fix stepper flow * show dialog on invalid token * fix app table refresh, pin icons light theme * cleanup contributor * inherit parent color, animations * use localized date pipe everywhere * cmp styles refactor, dont show granted p if none * fix navitem desc, fixed header * change permissions, caching * roles on org emit, use prom instead of hot obs * dont calc 100vh
31 lines
969 B
TypeScript
31 lines
969 B
TypeScript
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
|
|
import { AuthService } from 'src/app/services/auth.service';
|
|
|
|
|
|
@Directive({
|
|
selector: '[appHasRole]',
|
|
})
|
|
|
|
export class HasRoleDirective {
|
|
private hasView: boolean = false;
|
|
@Input() public set appHasRole(roles: string[]) {
|
|
if (roles && roles.length > 0) {
|
|
this.authService.isAllowed(roles).subscribe(isAllowed => {
|
|
if (isAllowed && !this.hasView) {
|
|
this.viewContainerRef.clear();
|
|
this.viewContainerRef.createEmbeddedView(this.templateRef);
|
|
} else if (this.hasView) {
|
|
this.viewContainerRef.clear();
|
|
this.hasView = false;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
constructor(
|
|
private authService: AuthService,
|
|
protected templateRef: TemplateRef<any>,
|
|
protected viewContainerRef: ViewContainerRef,
|
|
) { }
|
|
}
|