Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .server-changes/limit-account-email-length.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
area: webapp
type: fix
---

Limit account settings email input to 254 characters.
11 changes: 6 additions & 5 deletions apps/webapp/app/routes/account._index/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -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({
Expand All @@ -65,7 +64,8 @@ function createSchema(
});
});
}
}),
})
),
marketingEmails: z.preprocess((value) => value === "on", z.boolean()),
});
}
Expand Down Expand Up @@ -177,6 +177,7 @@ export default function Page() {
<div className="flex w-56 flex-none flex-col gap-1">
<Input
{...getInputProps(email, { type: "text" })}
maxLength={MAX_EMAIL_LENGTH}
placeholder="Your email"
defaultValue={user?.email ?? ""}
/>
Expand Down
14 changes: 8 additions & 6 deletions apps/webapp/app/routes/confirm-basic-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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,
Expand All @@ -93,8 +92,9 @@ function createSchema(
});
});
}
}),
confirmEmail: z.string(),
})
),
confirmEmail: emailSchema,
referralSource: z.string().optional(),
referralSourceOther: z.string().optional(),
role: z.string().optional(),
Expand Down Expand Up @@ -290,6 +290,7 @@ export default function Page() {
</Label>
<Input
{...getInputProps(email, { type: "email" })}
maxLength={MAX_EMAIL_LENGTH}
defaultValue={enteredEmail}
onChange={(e) => {
setEnteredEmail(e.target.value);
Expand All @@ -306,6 +307,7 @@ export default function Page() {
<Label htmlFor={confirmEmail.id}>Confirm email</Label>
<Input
{...getInputProps(confirmEmail, { type: "email" })}
maxLength={MAX_EMAIL_LENGTH}
placeholder="Your email, again"
icon={EnvelopeIcon}
spellCheck={false}
Expand Down
8 changes: 8 additions & 0 deletions apps/webapp/app/utils/emailValidation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { z } from "zod";

export const MAX_EMAIL_LENGTH = 254;

export const emailSchema = z
.string()
.email()
.max(MAX_EMAIL_LENGTH, `Email must be ${MAX_EMAIL_LENGTH} characters or fewer`);
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.