diff --git a/.server-changes/limit-account-email-length.md b/.server-changes/limit-account-email-length.md new file mode 100644 index 0000000000..2259f007e0 --- /dev/null +++ b/.server-changes/limit-account-email-length.md @@ -0,0 +1,6 @@ +--- +area: webapp +type: fix +--- + +Limit account settings email input to 254 characters. diff --git a/apps/webapp/app/routes/account._index/route.tsx b/apps/webapp/app/routes/account._index/route.tsx index 99ef9b87bb..341141e638 100644 --- a/apps/webapp/app/routes/account._index/route.tsx +++ b/apps/webapp/app/routes/account._index/route.tsx @@ -22,6 +22,7 @@ import { useUser } from "~/hooks/useUser"; import { redirectWithSuccessMessage } from "~/models/message.server"; import { updateUser } from "~/models/user.server"; import { requireUserId } from "~/services/session.server"; +import { emailSchema, MAX_EMAIL_LENGTH } from "~/utils/emailValidation"; import { accountPath } from "~/utils/pathBuilder"; export const meta: MetaFunction = () => { @@ -42,10 +43,8 @@ function createSchema( .string({ required_error: "You must enter a name" }) .min(2, "Your name must be at least 2 characters long") .max(50), - email: z - .string() - .email() - .superRefine((email, ctx) => { + email: emailSchema.pipe( + z.string().superRefine((email, ctx) => { if (constraints.isEmailUnique === undefined) { //client-side validation skips this ctx.addIssue({ @@ -65,7 +64,8 @@ function createSchema( }); }); } - }), + }) + ), marketingEmails: z.preprocess((value) => value === "on", z.boolean()), }); } @@ -177,6 +177,7 @@ export default function Page() {
diff --git a/apps/webapp/app/routes/confirm-basic-details.tsx b/apps/webapp/app/routes/confirm-basic-details.tsx index 9187823a73..4e37091324 100644 --- a/apps/webapp/app/routes/confirm-basic-details.tsx +++ b/apps/webapp/app/routes/confirm-basic-details.tsx @@ -27,6 +27,7 @@ import { useUser } from "~/hooks/useUser"; import { redirectWithSuccessMessage } from "~/models/message.server"; import { updateUser } from "~/models/user.server"; import { requireUserId } from "~/services/session.server"; +import { emailSchema, MAX_EMAIL_LENGTH } from "~/utils/emailValidation"; import { rootPath } from "~/utils/pathBuilder"; import { getVercelInstallParams } from "~/v3/vercel"; @@ -72,10 +73,8 @@ function createSchema( return z .object({ name: z.string().min(3, "Your name must be at least 3 characters").max(50), - email: z - .string() - .email() - .superRefine((email, ctx) => { + email: emailSchema.pipe( + z.string().superRefine((email, ctx) => { if (constraints.isEmailUnique === undefined) { ctx.addIssue({ code: z.ZodIssueCode.custom, @@ -93,8 +92,9 @@ function createSchema( }); }); } - }), - confirmEmail: z.string(), + }) + ), + confirmEmail: emailSchema, referralSource: z.string().optional(), referralSourceOther: z.string().optional(), role: z.string().optional(), @@ -290,6 +290,7 @@ export default function Page() { { setEnteredEmail(e.target.value); @@ -306,6 +307,7 @@ export default function Page() {