USER_NAME_MAX_LENGTH & USER_USERNAME_MAX_LENGTH

This commit is contained in:
Oliver Bryan
2026-01-10 18:55:58 +00:00
parent e2195e395b
commit 566fabccb5
4 changed files with 13 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
/** biome-ignore-all lint/correctness/useExhaustiveDependencies: <> */ /** biome-ignore-all lint/correctness/useExhaustiveDependencies: <> */
import { USER_NAME_MAX_LENGTH, USER_USERNAME_MAX_LENGTH } from "@issue/shared";
import { AlertTriangle, X } from "lucide-react"; import { AlertTriangle, X } from "lucide-react";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { useNavigate, useSearchParams } from "react-router-dom"; import { useNavigate, useSearchParams } from "react-router-dom";
@@ -246,6 +247,7 @@ export default function LogInForm() {
validate={(v) => (v.trim() === "" ? "Cannot be empty" : undefined)} validate={(v) => (v.trim() === "" ? "Cannot be empty" : undefined)}
submitAttempted={submitAttempted} submitAttempted={submitAttempted}
spellcheck={false} spellcheck={false}
maxLength={USER_NAME_MAX_LENGTH}
/> />
</> </>
)} )}
@@ -256,6 +258,8 @@ export default function LogInForm() {
validate={(v) => (v.trim() === "" ? "Cannot be empty" : undefined)} validate={(v) => (v.trim() === "" ? "Cannot be empty" : undefined)}
submitAttempted={submitAttempted} submitAttempted={submitAttempted}
spellcheck={false} spellcheck={false}
maxLength={USER_USERNAME_MAX_LENGTH}
showCounter={mode === "register"}
/> />
<Field <Field
label="Password" label="Password"

View File

@@ -1,3 +1,6 @@
export const USER_NAME_MAX_LENGTH = 64;
export const USER_USERNAME_MAX_LENGTH = 32;
export const ORG_NAME_MAX_LENGTH = 256; export const ORG_NAME_MAX_LENGTH = 256;
export const ORG_DESCRIPTION_MAX_LENGTH = 1024; export const ORG_DESCRIPTION_MAX_LENGTH = 1024;
export const ORG_SLUG_MAX_LENGTH = 64; export const ORG_SLUG_MAX_LENGTH = 64;

View File

@@ -8,6 +8,8 @@ export {
PROJECT_DESCRIPTION_MAX_LENGTH, PROJECT_DESCRIPTION_MAX_LENGTH,
PROJECT_NAME_MAX_LENGTH, PROJECT_NAME_MAX_LENGTH,
PROJECT_SLUG_MAX_LENGTH, PROJECT_SLUG_MAX_LENGTH,
USER_NAME_MAX_LENGTH,
USER_USERNAME_MAX_LENGTH,
} from "./constants"; } from "./constants";
export type { export type {

View File

@@ -9,12 +9,14 @@ import {
ORG_NAME_MAX_LENGTH, ORG_NAME_MAX_LENGTH,
ORG_SLUG_MAX_LENGTH, ORG_SLUG_MAX_LENGTH,
PROJECT_NAME_MAX_LENGTH, PROJECT_NAME_MAX_LENGTH,
USER_NAME_MAX_LENGTH,
USER_USERNAME_MAX_LENGTH,
} from "./constants"; } from "./constants";
export const User = pgTable("User", { export const User = pgTable("User", {
id: integer().primaryKey().generatedAlwaysAsIdentity(), id: integer().primaryKey().generatedAlwaysAsIdentity(),
name: varchar({ length: 256 }).notNull(), name: varchar({ length: USER_NAME_MAX_LENGTH }).notNull(),
username: varchar({ length: 32 }).notNull().unique(), username: varchar({ length: USER_USERNAME_MAX_LENGTH }).notNull().unique(),
passwordHash: varchar({ length: 255 }).notNull(), passwordHash: varchar({ length: 255 }).notNull(),
avatarURL: varchar({ length: 512 }), avatarURL: varchar({ length: 512 }),
createdAt: timestamp({ withTimezone: false }).defaultNow(), createdAt: timestamp({ withTimezone: false }).defaultNow(),