本文整理汇总了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();
}
}