chatbot-template/auth.ts

31 lines
641 B
TypeScript
Raw Normal View History

2023-06-16 11:49:14 -04:00
import NextAuth from 'next-auth'
import GitHub from 'next-auth/providers/github'
export const {
handlers: { GET, POST },
auth,
CSRF_experimental
2023-06-16 12:03:09 -04:00
// @ts-ignore
2023-06-16 11:49:14 -04:00
} = NextAuth({
// @ts-ignore
providers: [GitHub],
callbacks: {
2023-06-16 12:03:09 -04:00
// @ts-ignore
2023-06-16 11:49:14 -04:00
jwt: async ({ token, profile }) => {
if (profile?.id) {
token.id = profile.id
token.image = profile.picture
}
return token
}
2023-06-16 13:01:52 -04:00
// // @ts-ignore
2023-06-16 12:58:52 -04:00
// authorized({ request, auth }) {
2023-06-16 13:01:52 -04:00
// if (!request.nextUrl.pathname.startsWith('/share/')) return false
2023-06-16 12:58:52 -04:00
// return !!auth?.user
// }
2023-06-16 11:49:14 -04:00
},
pages: {
signIn: '/sign-in'
}
})