-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.ts
31 lines (28 loc) · 839 Bytes
/
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
import NextAuth from 'next-auth'
import GitHub from 'next-auth/providers/github'
import Google from 'next-auth/providers/google'
import { DrizzleAdapter } from '@auth/drizzle-adapter'
import { db } from './db/db'
import type { Provider } from 'next-auth/providers'
const providers: Provider[] = [GitHub, Google]
export const { handlers, signIn, signOut, auth } = NextAuth({
adapter: DrizzleAdapter(db),
providers,
callbacks: {
session({ session, user }) {
session.user.id = user.id
return session
},
},
pages: {
signIn: '/signin',
},
})
export const providerMap = providers.map((provider) => {
if (typeof provider === 'function') {
const providerData = provider()
return { id: providerData.id, name: providerData.name }
} else {
return { id: provider.id, name: provider.name }
}
})