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() {