11import type { NextAuthOptions } from "next-auth" ;
22import GoogleProvider from "next-auth/providers/google" ;
3+ import GithubProvider from "next-auth/providers/github" ;
34import { serverTrpc } from "../trpc-server" ;
45
56export const authConfig : NextAuthOptions = {
@@ -8,14 +9,21 @@ export const authConfig: NextAuthOptions = {
89 clientId : process . env . GOOGLE_CLIENT_ID ! ,
910 clientSecret : process . env . GOOGLE_CLIENT_SECRET ! ,
1011 } ) ,
12+ GithubProvider ( {
13+ clientId : process . env . GITHUB_CLIENT_ID ! ,
14+ clientSecret : process . env . GITHUB_CLIENT_SECRET ! ,
15+ authorization : {
16+ params : { scope : "read:user user:email" } ,
17+ } ,
18+ } ) ,
1119 ] ,
1220 callbacks : {
13- async signIn ( { user, profile } ) {
21+ async signIn ( { user, profile, account } ) {
1422 try {
1523 await serverTrpc . auth . googleAuth . mutate ( {
1624 email : user . email ! ,
17- firstName : profile ?. name ,
18- authMethod : "google" ,
25+ firstName : user . name ?? ( profile as any ) ?. name ,
26+ authMethod : account ?. provider ?? "google" ,
1927 } ) ;
2028
2129 return true ;
@@ -39,7 +47,7 @@ export const authConfig: NextAuthOptions = {
3947 const data = await serverTrpc . auth . googleAuth . mutate ( {
4048 email : user . email ! ,
4149 firstName : user . name ?? undefined ,
42- authMethod : "google" ,
50+ authMethod : account . provider ?? "google" ,
4351 } ) ;
4452
4553 token . jwtToken = data . token ;
0 commit comments