From 09436c78fc6d5440cf48dcc2d2adc20ef6f83a3b Mon Sep 17 00:00:00 2001 From: Shubham Palriwala Date: Fri, 11 Aug 2023 20:06:26 +0530 Subject: [PATCH] Validate for E-Mail Address on Verification Page (#666) * validate: for email in the user verification modal * feat: email auth is now a server page, uses server-side zod lib for email input validation, removes validator lib * Add FormWrapper to Error Message --------- Co-authored-by: Matthias Nannt --- .../auth/verification-requested/page.tsx | 37 +++++++++++-------- pnpm-lock.yaml | 12 +++--- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/apps/web/app/(auth)/auth/verification-requested/page.tsx b/apps/web/app/(auth)/auth/verification-requested/page.tsx index 82264adfb9..5c5a42534a 100644 --- a/apps/web/app/(auth)/auth/verification-requested/page.tsx +++ b/apps/web/app/(auth)/auth/verification-requested/page.tsx @@ -1,33 +1,38 @@ -"use client"; - import { RequestVerificationEmail } from "@/components/auth/RequestVerificationEmail"; -import { useSearchParams } from "next/navigation"; import FormWrapper from "@/components/auth/FormWrapper"; +import { z } from "zod"; -export default function VerficationPage() { - const searchParams = useSearchParams(); - return ( - - {searchParams && searchParams?.get("email") ? ( +const VerificationPageSchema = z.string().email(); + +export default function VerificationPage(params) { + const email = params.searchParams.email; + try { + const parsedEmail = VerificationPageSchema.parse(email); + return ( + <>

Please confirm your email address

- We sent an email to {searchParams.get("email")}. - Please click the link in the email to activate your account. + We sent an email to {parsedEmail}. Please click the + link in the email to activate your account.


You didn't receive an email or your link expired?

- +
- ) : ( -

No E-Mail Address provided

- )} -
- ); +
+ ); + } catch (error) { + return ( + +

Invalid email address

+
+ ); + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3b99627b33..f3e2614499 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -352,7 +352,7 @@ importers: version: 8.10.0(eslint@8.46.0) eslint-config-turbo: specifier: latest - version: 1.8.8(eslint@8.46.0) + version: 1.10.3(eslint@8.46.0) eslint-plugin-react: specifier: 7.33.1 version: 7.33.1(eslint@8.46.0) @@ -9837,13 +9837,13 @@ packages: eslint: 8.46.0 dev: true - /eslint-config-turbo@1.8.8(eslint@8.46.0): - resolution: {integrity: sha512-+yT22sHOT5iC1sbBXfLIdXfbZuiv9bAyOXsxTxFCWelTeFFnANqmuKB3x274CFvf7WRuZ/vYP/VMjzU9xnFnxA==} + /eslint-config-turbo@1.10.3(eslint@8.46.0): + resolution: {integrity: sha512-ggzPfTJfMsMS383oZ4zfTP1zQvyMyiigOQJRUnLt1nqII6SKkTzdKZdwmXRDHU24KFwUfEFtT6c8vnm2VhL0uQ==} peerDependencies: eslint: '>6.6.0' dependencies: eslint: 8.46.0 - eslint-plugin-turbo: 1.8.8(eslint@8.46.0) + eslint-plugin-turbo: 1.10.3(eslint@8.46.0) dev: true /eslint-import-resolver-node@0.3.6: @@ -10031,8 +10031,8 @@ packages: semver: 6.3.1 string.prototype.matchall: 4.0.8 - /eslint-plugin-turbo@1.8.8(eslint@8.46.0): - resolution: {integrity: sha512-zqyTIvveOY4YU5jviDWw9GXHd4RiKmfEgwsjBrV/a965w0PpDwJgEUoSMB/C/dU310Sv9mF3DSdEjxjJLaw6rA==} + /eslint-plugin-turbo@1.10.3(eslint@8.46.0): + resolution: {integrity: sha512-g3Mnnk7el1FqxHfqbE/MayLvCsYjA/vKmAnUj66kV4AlM7p/EZqdt42NMcMSKtDVEm0w+utQkkzWG2Xsa0Pd/g==} peerDependencies: eslint: '>6.6.0' dependencies: