Skip to content

Commit

Permalink
fix: return null from getValidIdToken if provided server token is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogrodzki committed Jun 17, 2024
1 parent a35dc09 commit 613f230
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/next/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export async function getValidIdToken({
refreshTokenUrl,
checkRevoked
}: GetValidIdTokenOptions): Promise<string | null> {
// If serverIdToken is empty, we assume user is unauthenticated and token refresh will yield null
if (!serverIdToken) {
return null;
}

const token = getLatestIdToken(serverIdToken);
const payload = decodeJwt(token);
const exp = payload?.exp ?? 0;
Expand Down

0 comments on commit 613f230

Please sign in to comment.