Skip to content

Commit b8e663e

Browse files
committed
feat: add maxLength constraints to auth and settings form inputs
Gives users immediate client-side feedback and prevents pathologically long values from being typed. Caps match Zod schema limits where they exist; email uses the RFC 5321 maximum. Files touched (5): - (home)/login/LocalLoginForm.tsx — email → 254 - (home)/register/page.tsx — email → 254 - dashboard/.../user-settings/.../ProfileContent.tsx — display name → 100 - components/settings/general-settings-manager.tsx — search space name → 100 - components/settings/roles-manager.tsx — role name (create+edit dialogs) → 100, role description (create+edit dialogs) → 500 Closes #948
1 parent 4e68565 commit b8e663e

5 files changed

Lines changed: 8 additions & 0 deletions

File tree

surfsense_web/app/(home)/login/LocalLoginForm.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export function LocalLoginForm() {
158158
type="email"
159159
autoComplete="username"
160160
required
161+
maxLength={254}
161162
placeholder="you@example.com"
162163
value={username}
163164
onChange={(e) => setUsername(e.target.value)}

surfsense_web/app/(home)/register/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ export default function RegisterPage() {
237237
type="email"
238238
autoComplete="email"
239239
required
240+
maxLength={254}
240241
placeholder="you@example.com"
241242
value={email}
242243
onChange={(e) => setEmail(e.target.value)}

surfsense_web/app/dashboard/[search_space_id]/user-settings/components/ProfileContent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export function ProfileContent() {
9494
id="display-name"
9595
type="text"
9696
autoComplete="name"
97+
maxLength={100}
9798
placeholder={user?.email?.split("@")[0]}
9899
value={displayName}
99100
onChange={(e) => setDisplayName(e.target.value)}

surfsense_web/components/settings/general-settings-manager.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export function GeneralSettingsManager({ searchSpaceId }: GeneralSettingsManager
148148
<Label htmlFor="search-space-name">{t("general_name_label")}</Label>
149149
<Input
150150
id="search-space-name"
151+
maxLength={100}
151152
placeholder={t("general_name_placeholder")}
152153
value={name}
153154
onChange={(e) => setName(e.target.value)}

surfsense_web/components/settings/roles-manager.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,7 @@ function CreateRoleDialog({
876876
<Label htmlFor="role-name">Role Name *</Label>
877877
<Input
878878
id="role-name"
879+
maxLength={100}
879880
placeholder="e.g., Content Manager"
880881
value={name}
881882
onChange={(e) => setName(e.target.value)}
@@ -885,6 +886,7 @@ function CreateRoleDialog({
885886
<Label htmlFor="role-description">Description</Label>
886887
<Input
887888
id="role-description"
889+
maxLength={500}
888890
placeholder="Brief description of this role"
889891
value={description}
890892
onChange={(e) => setDescription(e.target.value)}
@@ -1034,6 +1036,7 @@ function EditRoleDialog({
10341036
<Label htmlFor="edit-role-name">Role Name *</Label>
10351037
<Input
10361038
id="edit-role-name"
1039+
maxLength={100}
10371040
placeholder="e.g., Content Manager"
10381041
value={name}
10391042
onChange={(e) => setName(e.target.value)}
@@ -1043,6 +1046,7 @@ function EditRoleDialog({
10431046
<Label htmlFor="edit-role-description">Description</Label>
10441047
<Input
10451048
id="edit-role-description"
1049+
maxLength={500}
10461050
placeholder="Brief description of this role"
10471051
value={description}
10481052
onChange={(e) => setDescription(e.target.value)}

0 commit comments

Comments
 (0)