From 96bf46c88f29a4ab05d9aeb4fe8aff0c91e938f2 Mon Sep 17 00:00:00 2001 From: Kiran K Date: Tue, 15 Oct 2024 00:42:18 +0530 Subject: [PATCH 1/2] fix the email verification --- apps/web/app/api/auth/reset-password/route.ts | 10 ++++++++++ apps/web/app/app.dub.co/(auth)/login/form.tsx | 10 ++-------- apps/web/lib/middleware/app.ts | 1 - 3 files changed, 12 insertions(+), 9 deletions(-) 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/") ) { From a76392c676084c63bf662f50f91a163357700634 Mon Sep 17 00:00:00 2001 From: Steven Tey Date: Mon, 14 Oct 2024 12:12:18 -0700 Subject: [PATCH 2/2] digits: 1 --- apps/web/ui/layout/sidebar/usage.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/web/ui/layout/sidebar/usage.tsx b/apps/web/ui/layout/sidebar/usage.tsx index 641febb08f..9c5fc6f831 100644 --- a/apps/web/ui/layout/sidebar/usage.tsx +++ b/apps/web/ui/layout/sidebar/usage.tsx @@ -181,4 +181,7 @@ function UsageRow({ const formatNumber = (value: number) => value >= 1000000000 ? "∞" - : nFormatter(value, { full: value !== undefined && value < 9999 }); + : nFormatter(value, { + full: value !== undefined && value < 9999, + digits: 1, + });