This commit is contained in:
Giuseppe Digilio
2018-04-10 14:27:32 +02:00
parent 0ed1f7778e
commit 1f953b6b9d
2 changed files with 31 additions and 17 deletions

View File

@@ -8,8 +8,12 @@ export class AuthTokenInfo {
constructor(token: string) {
this.accessToken = token.replace('Bearer ', '');
const tokenClaims = decode(this.accessToken);
// exp claim is in seconds, convert it se to milliseconds
this.expires = tokenClaims.exp * 1000;
try {
const tokenClaims = decode(this.accessToken);
// exp claim is in seconds, convert it se to milliseconds
this.expires = tokenClaims.exp * 1000;
} catch (err) {
this.expires = 0;
}
}
}