The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update [...nextauth].tsx
Steven Tey5f3f9096c4bc
diff --git a/pages/api/auth/[...nextauth].tsx b/pages/api/auth/[...nextauth].tsxindex b3a4a7ed7a..85fff2b8d9 100644--- a/pages/api/auth/[...nextauth].tsx+++ b/pages/api/auth/[...nextauth].tsx@@ -105,16 +105,17 @@ export const authOptions: NextAuthOptions = {return null;}- const actualUser = await prisma.user.findUnique({+ const existingUser = await prisma.user.findUnique({where: { email: userInfo.email },});// user is authorized but doesn't have a Dub account, prompt them to create one- if (!actualUser) {+ if (!existingUser) {+ console.log("NO SUCH USER, PROMPT TO CREATE");return null;}- const { id, name, email, image } = actualUser;+ const { id, name, email, image } = existingUser;return {id,@@ -170,12 +171,16 @@ export const authOptions: NextAuthOptions = {return true;},jwt: async ({ token, user, trigger }) => {+ // force log out banned usersif (!token.email || (await isBlacklistedEmail(token.email))) {return {};}+if (user) {token.user = user;}++ // refresh the user's data if they update their name / emailif (trigger === "update") {const refreshedUser = await prisma.user.findUnique({where: { id: token.sub },