|
|
@@ -5,7 +5,8 @@ import { LOGIN_API_PATH } from "./api"; |
|
|
|
export interface SessionWithTokens extends Session { |
|
|
|
accessToken: string | null; |
|
|
|
refreshToken?: string; |
|
|
|
abilities: string[] |
|
|
|
abilities: string[]; |
|
|
|
id?: string | null |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -27,6 +28,7 @@ export const authOptions: AuthOptions = { |
|
|
|
}); |
|
|
|
|
|
|
|
const user = await res.json(); |
|
|
|
|
|
|
|
|
|
|
|
if (res.ok && user) { |
|
|
|
return user; |
|
|
@@ -43,18 +45,17 @@ export const authOptions: AuthOptions = { |
|
|
|
// Add the data from user to the token |
|
|
|
const { token, user } = params; |
|
|
|
const newToken = { ...token, ...user }; |
|
|
|
|
|
|
|
return newToken; |
|
|
|
}, |
|
|
|
session({ session, token }) { |
|
|
|
const sessionWithToken: SessionWithTokens = { |
|
|
|
...session, |
|
|
|
// Add the data from the token to the session |
|
|
|
id: token.id as string | undefined, |
|
|
|
accessToken: token.accessToken as string | null, |
|
|
|
refreshToken: token.refreshToken as string | undefined, |
|
|
|
abilities: token.abilities as string[] |
|
|
|
}; |
|
|
|
|
|
|
|
return sessionWithToken; |
|
|
|
}, |
|
|
|
}, |
|
|
|