RED-4482: logout when session expires

This commit is contained in:
Dan Percic 2022-07-13 20:27:58 +03:00
parent e69c5be7b7
commit 4714beec30
2 changed files with 10 additions and 2 deletions

View File

@ -65,7 +65,15 @@ export class UserService extends EntitiesService<IUser, User> {
const userId = (<{ sub: string }>decoded).sub;
const roles = this._keycloakService.getUserRoles(true).filter(role => role.startsWith('RED_'));
const user = new User(await this._keycloakService.loadUserProfile(true), roles, userId);
let profile;
try {
profile = await this._keycloakService.loadUserProfile(true);
} catch (e) {
await this._keycloakService.logout();
console.log(e);
}
const user = new User(profile, roles, userId);
this.replace(user);
this.#currentUser$.next(this.find(userId));

View File

@ -5,7 +5,7 @@ export class GlobalErrorHandler extends ErrorHandler {
handleError(error: Error): void {
const chunkFailedMessage = /Loading chunk [\d]+ failed/;
console.write(error);
if (error.message?.includes('An error happened during access validation')) {
if (error?.message?.includes('An error happened during access validation')) {
console.log('User is not authorized to access this page');
}