mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
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:
@@ -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}`, {
|
||||||
|
|||||||
Reference in New Issue
Block a user