RED-5700 - logout error on session expired

This commit is contained in:
Timo Bejan 2023-01-10 14:16:46 +08:00
parent 4a8402f7eb
commit b20d4e938c

View File

@ -59,7 +59,16 @@ export abstract class IqserUserService<
async logout() { async logout() {
await this._cacheApiService.wipeCaches(); await this._cacheApiService.wipeCaches();
await this._keycloakService.logout(); if(await this._keycloakService.isLoggedIn()) {
await this._keycloakService.logout();
}
window.location.href = this._keycloakService.getKeycloakInstance().createLoginUrl({
redirectUri: window.location.origin + this._baseHref,
});
}
async redirectToLogin(){
await this._cacheApiService.wipeCaches();
window.location.href = this._keycloakService.getKeycloakInstance().createLoginUrl({ window.location.href = this._keycloakService.getKeycloakInstance().createLoginUrl({
redirectUri: window.location.origin + this._baseHref, redirectUri: window.location.origin + this._baseHref,
}); });
@ -80,8 +89,8 @@ export abstract class IqserUserService<
throw new Error('No user id'); throw new Error('No user id');
} }
} catch (e) { } catch (e) {
console.log(e); console.log("Load KC profile failed");
await this.logout(); await this.redirectToLogin();
return; return;
} }