mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Refactoring
This commit is contained in:
+25
-1
@@ -52,6 +52,7 @@ export const {handlers, auth: baseAuth, signIn, signOut} = NextAuth({
|
||||
name: profile.name,
|
||||
email: profile.email,
|
||||
image: profile.picture,
|
||||
authMethod: "google",
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -66,8 +67,31 @@ export const {handlers, auth: baseAuth, signIn, signOut} = NextAuth({
|
||||
callbacks: {
|
||||
session({session, user, token}) {
|
||||
// session.user.role = user.role
|
||||
// session.user.authMethod = user.authMethod;
|
||||
return session
|
||||
}
|
||||
},
|
||||
async signIn({ account, user }) {
|
||||
console.log(account)
|
||||
// const authMethod = account.provider === 'credentials' ? 'credentials' : 'oauth';
|
||||
user = await prisma.user.findFirst({
|
||||
where: {
|
||||
email: user.email,
|
||||
}
|
||||
})
|
||||
if (!user) {
|
||||
return true
|
||||
}
|
||||
console.log(user)
|
||||
// Update the user in the database with the auth method
|
||||
await prisma.user.update({
|
||||
where: { id: user.id },
|
||||
data: {
|
||||
authMethod: account.provider
|
||||
},
|
||||
});
|
||||
|
||||
return true;
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user