update user & auth

This commit is contained in:
Dan Percic 2022-07-27 13:25:51 +03:00
parent 34b7ebcef7
commit 3906421aa0
2 changed files with 6 additions and 7 deletions

View File

@ -35,8 +35,8 @@ function getKeycloakOptions(baseUrl: string, configService: BaseConfigService):
}
function configureAutomaticRedirectToLoginScreen(keyCloakService: KeycloakService) {
keyCloakService.getKeycloakInstance().onAuthRefreshError = () => {
void keyCloakService.logout().then();
keyCloakService.getKeycloakInstance().onAuthRefreshError = async () => {
await keyCloakService.logout();
};
}
@ -53,7 +53,6 @@ export function keycloakInitializer(
imports: [CommonModule, HttpClientModule, KeycloakAngularModule],
providers: [
AuthGuard,
RoleGuard,
{
provide: APP_INITIALIZER,
useFactory: keycloakInitializer,

View File

@ -49,9 +49,9 @@ export abstract class BaseUserService<
await firstValueFrom(this.loadAll());
}
logout() {
void this._cacheApiService.wipeCaches().then();
void this._keycloakService.logout(window.location.origin + this._baseHref).then();
async logout() {
await this._cacheApiService.wipeCaches();
await this._keycloakService.logout(window.location.origin + this._baseHref);
}
loadAll() {
@ -71,8 +71,8 @@ export abstract class BaseUserService<
try {
profile = await this._keycloakService.loadUserProfile(true);
} catch (e) {
await this._keycloakService.logout();
console.log(e);
await this.logout();
return;
}