本文整理匯總了TypeScript中app/core/auth/principal.service.Principal類的典型用法代碼示例。如果您正苦於以下問題:TypeScript service.Principal類的具體用法?TypeScript service.Principal怎麽用?TypeScript service.Principal使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了service.Principal類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
(err: any) => {
if (err instanceof HttpErrorResponse) {
if (err.status === 401) {
if (this.principal.isAuthenticated()) {
this.principal.authenticate(null);
this.loginModalService.open();
} else {
this.loginService.logout();
this.router.navigate(['/']);
}
}
}
}
示例2: jhiHasAnyAuthority
@Input()
set jhiHasAnyAuthority(value: string | string[]) {
this.authorities = typeof value === 'string' ? [value] : value;
this.updateView();
// Get notified each time authentication state changes.
this.principal.getAuthenticationState().subscribe(identity => this.updateView());
}
示例3: updateView
private updateView(): void {
this.principal.hasAnyAuthority(this.authorities).then(result => {
this.viewContainerRef.clear();
if (result) {
this.viewContainerRef.createEmbeddedView(this.templateRef);
}
});
}
示例4: logout
logout() {
this.authServerProvider.logout().subscribe();
this.principal.authenticate(null);
}
示例5: cb
(data) => {
this.principal.identity(true).then((account) => {
resolve(data);
});
return cb();
},