本文整理匯總了TypeScript中keycloak-angular.KeycloakService類的典型用法代碼示例。如果您正苦於以下問題:TypeScript KeycloakService類的具體用法?TypeScript KeycloakService怎麽用?TypeScript KeycloakService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了KeycloakService類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Promise
return new Promise(async (resolve, reject) => {
try {
keycloak.keycloakEvents$.subscribe(event => {
eventStackService.triggerEvent(event);
});
await keycloak.init({
config: environment.keycloak
});
resolve();
} catch (error) {
reject(error);
}
});
示例2: Promise
return new Promise(async (resolve, reject) => {
try {
await keycloak.init({
config: environment.keycloak,
initOptions: {
onLoad: 'login-required',
checkLoginIframe: false
},
bearerExcludedUrls: []
});
resolve();
} catch (error) {
reject(error);
}
});
示例3: Promise
return new Promise(async (resolve, reject) => {
if (!this.authenticated) {
this.keycloakAngular.login();
return;
}
const requiredRoles = route.data.roles;
if (!requiredRoles || requiredRoles.length === 0) {
return resolve(true);
} else {
if (!this.roles || this.roles.length === 0) {
resolve(false);
}
let granted: boolean = false;
for (const requiredRole of requiredRoles) {
if (this.roles.indexOf(requiredRole) > -1) {
granted = true;
break;
}
}
resolve(granted);
}
});
示例4: doLogout
async doLogout() {
await this.keycloakService.logout();
}
示例5: ngOnInit
async ngOnInit() {
if (await this.keycloakService.isLoggedIn()) {
this.userDetails = await this.keycloakService.loadUserProfile();
}
}