Scheduling infrastructure for absolutely everyone.
Get user from token as required for magic login to work (#4163)
Hariom Balhara10815c954119
diff --git a/apps/web/pages/api/auth/[...nextauth].tsx b/apps/web/pages/api/auth/[...nextauth].tsxindex 8b685b0c3c0..720c5e82709 100644--- a/apps/web/pages/api/auth/[...nextauth].tsx+++ b/apps/web/pages/api/auth/[...nextauth].tsx@@ -215,29 +215,24 @@ export default NextAuth({callbacks: {async jwt({ token, user, account }) {const autoMergeIdentities = async () => {- if (!hostedCal) {- const existingUser = await prisma.user.findFirst({- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion- where: { email: token.email! },- });-- if (!existingUser) {- return token;- }+ const existingUser = await prisma.user.findFirst({+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ where: { email: token.email! },+ });- return {- id: existingUser.id,- username: existingUser.username,- name: existingUser.name,- email: existingUser.email,- role: existingUser.role,- impersonatedByUID: token?.impersonatedByUID as number,- };+ if (!existingUser) {+ return token;}- return token;+ return {+ id: existingUser.id,+ username: existingUser.username,+ name: existingUser.name,+ email: existingUser.email,+ role: existingUser.role,+ impersonatedByUID: token?.impersonatedByUID as number,+ };};-if (!user) {return await autoMergeIdentities();}