Return null principal if the expiredAt is actually expired
This commit is contained in:
parent
b3bf7ab73d
commit
8ffb306913
|
@ -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) => {
|
||||
|
|
Loading…
Reference in New Issue