diff --git a/dmp-frontend/src/app/core/services/auth/auth.service.ts b/dmp-frontend/src/app/core/services/auth/auth.service.ts index af4604994..d871e6db7 100644 --- a/dmp-frontend/src/app/core/services/auth/auth.service.ts +++ b/dmp-frontend/src/app/core/services/auth/auth.service.ts @@ -49,7 +49,11 @@ export class AuthService extends BaseService { } const principalJson = localStorage.getItem('principal'); if (!principalJson) { return null; } - const principalObj = JSON.parse(principalJson) as Principal; + let principalObj = JSON.parse(principalJson) as Principal; + principalObj.expiresAt = new Date(principalObj.expiresAt); + if (principalObj.expiresAt < new Date()) { + return null; + } return principalObj; } @@ -132,6 +136,8 @@ export class AuthService extends BaseService { return this.http.post(url, null, { headers: headers }).pipe( map((res: any) => { const princ = this.current(res.payload); + princ.expiresAt = new Date(princ.expiresAt); + console.log("Token Expires at: " + princ.expiresAt.toDateString() + ' ' + princ.expiresAt.toLocaleTimeString()); return princ; }), catchError((error: any) => {