-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.ts
33 lines (29 loc) · 1.03 KB
/
auth.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import NextAuth from "next-auth"
import authConfig from "./auth.config"
import { FirestoreAdapter } from "@auth/firebase-adapter"
import { firestore } from "@/lib/firestore"
export const { handlers, signIn, signOut, auth } = NextAuth({
adapter: FirestoreAdapter(firestore),
session: { strategy: 'jwt' },
callbacks: {
// Thank god for this
// https://github.com/nextauthjs/next-auth/issues/7913
jwt: async ({ token, account }) => {
if (account && account.access_token) {
token.accessToken = account.access_token; // <-- adding the access_token here
token.provider = account.provider;
token.providerId = account.providerAccountId;
}
return token
},
session: async ({ session, token }) => {
// If we want to make the accessToken available in components, then we have to explicitly forward it here.
return { ...session,
access_token: token.accessToken,
provider: token.provider,
providerId: token.providerId
}
},
},
...authConfig
})