mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-12 09:05:12 +00:00
* es lint * modify tsconfig, auto lint some stuff * lint * lint * lint * lint * html ts lint * lint * lint, tsconfig * fix project delete, state table * eslint config, remove cnslHint directive * mfa selector, info row fixes * lint * fix login policy, granted orgs table state, lint Co-authored-by: Florian Forster <[email protected]>
31 lines
908 B
TypeScript
31 lines
908 B
TypeScript
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
|
|
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
|
|
|
|
|
|
@Directive({
|
|
selector: '[cnslHasFeature]',
|
|
})
|
|
|
|
export class HasFeatureDirective {
|
|
private hasView: boolean = false;
|
|
@Input() public set hasFeature(features: string[] | RegExp[]) {
|
|
if (features && features.length > 0) {
|
|
this.authService.canUseFeature(features).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: GrpcAuthService,
|
|
protected templateRef: TemplateRef<any>,
|
|
protected viewContainerRef: ViewContainerRef,
|
|
) { }
|
|
}
|