diff --git a/apps/web/pages/api/auth/signup.ts b/apps/web/pages/api/auth/signup.ts index 1358e14bbb..13551b66f0 100644 --- a/apps/web/pages/api/auth/signup.ts +++ b/apps/web/pages/api/auth/signup.ts @@ -12,7 +12,9 @@ import { IdentityProvider } from "@calcom/prisma/enums"; import { teamMetadataSchema } from "@calcom/prisma/zod-utils"; const signupSchema = z.object({ - username: z.string(), + username: z.string().refine((value) => !value.includes("+"), { + message: "String should not contain a plus symbol (+).", + }), email: z.string().email(), password: z.string().min(7), language: z.string().optional(), diff --git a/apps/web/pages/signup.tsx b/apps/web/pages/signup.tsx index 08d117f6b7..bb18fe4261 100644 --- a/apps/web/pages/signup.tsx +++ b/apps/web/pages/signup.tsx @@ -1,3 +1,4 @@ +import { zodResolver } from "@hookform/resolvers/zod"; import type { GetServerSidePropsContext } from "next"; import { signIn } from "next-auth/react"; import { useRouter } from "next/router"; @@ -23,13 +24,18 @@ import PageWrapper from "@components/PageWrapper"; import { IS_GOOGLE_LOGIN_ENABLED } from "../server/lib/constants"; import { ssrInit } from "../server/lib/ssr"; -type FormValues = { - username: string; - email: string; - password: string; - apiError: string; - token?: string; -}; +const signupSchema = z.object({ + username: z.string().refine((value) => !value.includes("+"), { + message: "String should not contain a plus symbol (+).", + }), + email: z.string().email(), + password: z.string().min(7), + language: z.string().optional(), + token: z.string().optional(), + apiError: z.string().optional(), // Needed to display API errors doesnt get passed to the API +}); + +type FormValues = z.infer; type SignupProps = inferSSRProps; @@ -39,6 +45,7 @@ export default function Signup({ prepopulateFormValues, token, orgSlug }: Signup const flags = useFlagMap(); const telemetry = useTelemetry(); const methods = useForm({ + resolver: zodResolver(signupSchema), defaultValues: prepopulateFormValues, }); const {