The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Redirect to OTP page on login attempt if email isn't verified
Tim Wilson90ac93d798b1
diff --git a/apps/web/app/app.dub.co/(auth)/login/form.tsx b/apps/web/app/app.dub.co/(auth)/login/form.tsxindex 17a10ef2da..0fe196013e 100644--- a/apps/web/app/app.dub.co/(auth)/login/form.tsx+++ b/apps/web/app/app.dub.co/(auth)/login/form.tsx@@ -368,6 +368,13 @@ const SignInWithEmail = () => {// Handle errorsif (!res.ok && res.error) {+ if (res.error === "email-not-verified") {+ router.push(+ `/register/verify-email?email=${encodeURIComponent(email)}`,+ );+ return;+ }+if (errorCodes[res.error]) {toast.error(errorCodes[res.error]);} else {diff --git a/apps/web/lib/auth/options.ts b/apps/web/lib/auth/options.tsindex 8230c25524..3e3f9f905f 100644--- a/apps/web/lib/auth/options.ts+++ b/apps/web/lib/auth/options.ts@@ -217,10 +217,6 @@ export const authOptions: NextAuthOptions = {throw new Error("invalid-credentials");}- if (!user.emailVerified) {- throw new Error("email-not-verified");- }-if (exceededLoginAttemptsThreshold(user)) {throw new Error("exceeded-login-attempts");}@@ -242,6 +238,10 @@ export const authOptions: NextAuthOptions = {}}+ if (!user.emailVerified) {+ throw new Error("email-not-verified");+ }+// Reset invalid login attemptsawait prisma.user.update({where: { id: user.id },