Ajustando definicao do AccessToken
This commit is contained in:
parent
05f4e4c1e6
commit
b23980922e
2 changed files with 4 additions and 3 deletions
|
@ -30,7 +30,8 @@ export interface AccessToken {
|
||||||
token_type: string;
|
token_type: string;
|
||||||
access_token: string;
|
access_token: string;
|
||||||
expires_in: number;
|
expires_in: number;
|
||||||
created_at: number;
|
scope?: string;
|
||||||
|
created_at?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum GrantType {
|
export enum GrantType {
|
||||||
|
|
|
@ -70,8 +70,8 @@ export default class LhispOauthClient {
|
||||||
|
|
||||||
isTokenValid(token: AccessToken){
|
isTokenValid(token: AccessToken){
|
||||||
if(!token) return false;
|
if(!token) return false;
|
||||||
const now = Date.now()
|
if(!token.created_at) return false;
|
||||||
const timeDiff = (now - token.created_at) / 1000;
|
const timeDiff = (Date.now() - token.created_at) / 1000;
|
||||||
return timeDiff < token.expires_in - 10;
|
return timeDiff < token.expires_in - 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue