solve mail backend 6

This commit is contained in:
alma 2025-04-17 13:59:39 +02:00
parent eba4df1e4d
commit 97068d5f6d

View File

@ -195,6 +195,31 @@ export const authOptions: NextAuthOptions = {
throw new Error("RefreshAccessTokenError");
}
try {
console.log('Creating/updating user in session callback:', {
id: token.sub,
email: token.email
});
// Create or update user in local database
await prisma.user.upsert({
where: { id: token.sub as string },
update: {
email: token.email as string,
password: '', // We don't store password for Keycloak users
},
create: {
id: token.sub as string,
email: token.email as string,
password: '', // We don't store password for Keycloak users
},
});
console.log('User created/updated successfully');
} catch (error) {
console.error('Error creating/updating user in session callback:', error);
}
session.accessToken = token.accessToken;
session.user = {
id: token.sub as string,