From 069bde6ad910d8f80e3c9070816f32a3fcdc6367 Mon Sep 17 00:00:00 2001 From: Mohammad Torkashvand <mohammad.torkashvand@geant.org> Date: Sun, 1 Sep 2024 13:29:33 +0200 Subject: [PATCH] refactor jwt code --- pages/api/auth/[...nextauth].ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pages/api/auth/[...nextauth].ts b/pages/api/auth/[...nextauth].ts index 3e19975..334d6c3 100644 --- a/pages/api/auth/[...nextauth].ts +++ b/pages/api/auth/[...nextauth].ts @@ -121,11 +121,13 @@ export const authOptions: AuthOptions = { async jwt({ token, account, profile }): Promise<JWT> { // The "account" is only available right after signing in -- adding useful data to the token if (account) { - token.accessToken = account.access_token; - token.refreshToken = account.refresh_token; - token.accessTokenExpires = account.expires_at as number; - - token.profile = profile as WfoUserProfile; + return { + ...token, + accessToken: account.access_token, + refreshToken: account.refresh_token, + accessTokenExpires: account.expires_at as number, + profile: profile as WfoUserProfile, + }; } const now = Math.floor(Date.now() / 1000); -- GitLab