diff --git a/src/app/services/user.service.ts b/src/app/services/user.service.ts index b5b98ed2ad8..cacae4f5574 100644 --- a/src/app/services/user.service.ts +++ b/src/app/services/user.service.ts @@ -101,6 +101,7 @@ export class UserService { } } catch (e) {} this.retrieveUser(credentials.username).subscribe((user) => { + this.redirectOnSessionExpire((user as any).expiresIn); return callback && callback(response); }); }); @@ -118,6 +119,17 @@ export class UserService { } } + redirectOnSessionExpire(expiresIn: string) { + if (expiresIn && expiresIn.length > 1) { + const durationMap = { 's': 1000, 'm': 60 * 1000 }; + const duration = Number(expiresIn.substring(0, expiresIn.length - 1)); + if (!Number.isNaN(duration)) { + const expiresAtMs = duration * durationMap[expiresIn.substring(expiresIn.length - 1)]; + setTimeout(() => window.location.reload(), expiresAtMs); + } + } + } + isGoogleIdExists(googleUserId: string) { let params = new HttpParams().set('googleUserId', googleUserId); return this.http.get(this.checkGoogleUserExistsUrl, { params: params });