Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) Fix undefined issue when expiresIn string is not available. #243

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading