fix: handle undefined access tokens in auth.ts

Added fallback to empty string for potentially undefined access_token
and refresh_token from NextAuth account object to satisfy
JWTWithAccessToken type requirements.
This commit is contained in:
2025-08-29 18:56:08 -06:00
parent 790b7992bb
commit 0df1b224f2

View File

@@ -38,11 +38,11 @@ export const authOptions: AuthOptions = {
// called only on first login // called only on first login
// XXX account.expires_in used in example is not defined for authentik backend, but expires_at is // XXX account.expires_in used in example is not defined for authentik backend, but expires_at is
const expiresAt = (account.expires_at as number) - PRETIMEOUT; const expiresAt = (account.expires_at as number) - PRETIMEOUT;
const jwtToken = { const jwtToken: JWTWithAccessToken = {
...extendedToken, ...extendedToken,
accessToken: account.access_token, accessToken: account.access_token || "",
accessTokenExpires: expiresAt * 1000, accessTokenExpires: expiresAt * 1000,
refreshToken: account.refresh_token, refreshToken: account.refresh_token || "",
}; };
// Store in memory cache // Store in memory cache
tokenCache.set(`token:${jwtToken.sub}`, { tokenCache.set(`token:${jwtToken.sub}`, {