Skip to content

Commit

Permalink
fix: decodedToken can be null, check it's not null before checking ex…
Browse files Browse the repository at this point in the history
…piry
  • Loading branch information
Yoshify committed Dec 17, 2024
1 parent 1c28f9a commit 7b229f5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/utils/jwt/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { jwtDecoder } from "@kinde/jwt-decoder";
// TODO: currently assumes that the token is valid
export const isTokenExpired = (token: string) => {
const decodedToken = jwtDecoder(token);

if(!decodedToken?.exp) {
return true;
}

return decodedToken.exp && decodedToken.exp < Date.now() / 1000;
}

Expand Down

0 comments on commit 7b229f5

Please sign in to comment.