mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 05:53:03 +00:00
Added refresh token functionality
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
import { default as decode } from 'jwt-decode';
|
||||
|
||||
export const TOKENITEM = 'dsAuthInfo';
|
||||
|
||||
export class AuthTokenInfo {
|
||||
public accessToken: string;
|
||||
public expires?: number;
|
||||
public expires: number;
|
||||
|
||||
constructor(token: string, expiresIn?: number) {
|
||||
constructor(token: string) {
|
||||
this.accessToken = token.replace('Bearer ', '');
|
||||
if (expiresIn) {
|
||||
this.expires = expiresIn * 1000 + Date.now();
|
||||
}
|
||||
const tokenClaims = decode(this.accessToken);
|
||||
// exp claim is in seconds, convert it se to milliseconds
|
||||
this.expires = tokenClaims.exp * 1000;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user