chatbot-template/auth.ts

30 lines
546 B
TypeScript
Raw Normal View History

import NextAuth from 'next-auth'
2023-06-16 11:49:14 -04:00
import GitHub from 'next-auth/providers/github'
export const {
handlers: { GET, POST },
auth,
CSRF_experimental
// @ts-ignore
2023-06-16 11:49:14 -04:00
} = NextAuth({
2023-06-21 11:17:59 -07:00
// @ts-ignore
2023-06-16 11:49:14 -04:00
providers: [GitHub],
callbacks: {
// @ts-ignore
2023-06-16 11:49:14 -04:00
jwt: async ({ token, profile }) => {
2023-06-21 14:19:13 -07:00
if (profile?.id) {
2023-06-16 11:49:14 -04:00
token.id = profile.id
token.image = profile.picture
}
return token
2023-06-22 10:37:35 -07:00
},
// @ts-ignore
authorized({ auth }) {
return !!auth?.user
2023-06-16 11:49:14 -04:00
}
},
pages: {
signIn: '/sign-in'
}
})