diff --git a/apps/web/app/api/auth/reset-password/route.ts b/apps/web/app/api/auth/reset-password/route.ts index 1a80f05eb2..1166c7e7ef 100644 --- a/apps/web/app/api/auth/reset-password/route.ts +++ b/apps/web/app/api/auth/reset-password/route.ts @@ -40,6 +40,15 @@ export async function POST(req: NextRequest) { const { identifier } = tokenFound; + const user = await prisma.user.findUniqueOrThrow({ + where: { + email: identifier, + }, + select: { + emailVerified: true, + }, + }); + await prisma.$transaction([ // Delete the token prisma.passwordResetToken.deleteMany({ @@ -56,6 +65,7 @@ export async function POST(req: NextRequest) { data: { passwordHash: await hashPassword(password), lockedAt: null, // Unlock the account after a successful password reset + ...(!user.emailVerified && { emailVerified: new Date() }), // Mark the email as verified }, }), ]); diff --git a/apps/web/app/app.dub.co/(auth)/login/form.tsx b/apps/web/app/app.dub.co/(auth)/login/form.tsx index e0bcf6e836..0562b62efe 100644 --- a/apps/web/app/app.dub.co/(auth)/login/form.tsx +++ b/apps/web/app/app.dub.co/(auth)/login/form.tsx @@ -44,6 +44,7 @@ const errorCodes = { "exceeded-login-attempts": "Account has been locked due to too many login attempts. Please contact support to unlock your account.", "too-many-login-attempts": "Too many login attempts. Please try again later.", + "email-not-verified": "Please verify your email address.", }; const LoginFormContext = createContext<{ @@ -388,20 +389,13 @@ const SignInWithEmail = () => { // Handle errors if (!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 { toast.error(res.error); } - setClickedMethod(undefined); + setClickedMethod(undefined); return; } diff --git a/apps/web/lib/middleware/app.ts b/apps/web/lib/middleware/app.ts index ccfd6cc5e5..b74b0b74f1 100644 --- a/apps/web/lib/middleware/app.ts +++ b/apps/web/lib/middleware/app.ts @@ -19,7 +19,6 @@ export default async function AppMiddleware(req: NextRequest) { path !== "/login" && path !== "/forgot-password" && path !== "/register" && - path !== "/register/verify-email" && path !== "/auth/saml" && !path.startsWith("/auth/reset-password/") ) {