Ajustando definicao do AccessToken

This commit is contained in:
Leandro Costa 2023-01-26 22:33:04 -03:00
parent 05f4e4c1e6
commit b23980922e
2 changed files with 4 additions and 3 deletions

View file

@ -30,7 +30,8 @@ export interface AccessToken {
token_type: string;
access_token: string;
expires_in: number;
created_at: number;
scope?: string;
created_at?: number;
}
export enum GrantType {

View file

@ -70,8 +70,8 @@ export default class LhispOauthClient {
isTokenValid(token: AccessToken){
if(!token) return false;
const now = Date.now()
const timeDiff = (now - token.created_at) / 1000;
if(!token.created_at) return false;
const timeDiff = (Date.now() - token.created_at) / 1000;
return timeDiff < token.expires_in - 10;
}