Skip to content

Commit

Permalink
Merge pull request #243 from Achintha444/master
Browse files Browse the repository at this point in the history
(fix) Fix `undefined` issue when `expiresIn` string is not available.
  • Loading branch information
Achintha444 authored Dec 11, 2023
2 parents e2678d1 + 130f2dc commit b1f875e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/src/core/authentication-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,16 @@ export class AuthenticationCore<T> {
// Check if the access token is expired.
const createdAt: number = await this.getCreatedAt(userID);

// Get the expires in value.
const expiresInString: string = await this.getExpiresIn(userID);

// If the expires in value is not available, the token is invalid and the user is not authenticated.
if (!expiresInString) {
return false;
}

// Convert to milliseconds.
const expiresIn: number = parseInt(await this.getExpiresIn(userID)) * 1000;
const expiresIn: number = parseInt(expiresInString) * 1000;
const currentTime: number = new Date().getTime();
const isAccessTokenValid: boolean = (createdAt + expiresIn) > currentTime;

Expand Down

0 comments on commit b1f875e

Please sign in to comment.