- normalize username and email fields to lowercase, resolves #1740

- add autoComplete attributes to auth flow for easier sign in/sign up
This commit is contained in:
Amruth Pillai
2025-01-12 15:13:11 +01:00
parent 92856b6f06
commit 89a44cc33a
12 changed files with 36 additions and 19 deletions

View File

@ -5,7 +5,7 @@ import { usernameSchema } from "../user";
export const loginSchema = z
.object({
identifier: z.string(),
identifier: z.string().transform((value) => value.toLowerCase()),
password: z.password().min(6),
})
.refine(

View File

@ -8,17 +8,20 @@ export const usernameSchema = z
.string()
.min(3)
.max(255)
.regex(/^[\d._a-z-]+$/, {
message:
"Usernames can only contain lowercase letters, numbers, periods, hyphens, and underscores.",
});
.regex(/^[\w.-]+$/, {
message: "Usernames can only contain letters, numbers, periods, hyphens, and underscores.",
})
.transform((value) => value.toLowerCase());
export const userSchema = z.object({
id: idSchema,
name: z.string().min(1).max(255),
picture: z.literal("").or(z.null()).or(z.string().url()),
username: usernameSchema,
email: z.string().email(),
email: z
.string()
.email()
.transform((value) => value.toLowerCase()),
locale: z.string().default("en-US"),
emailVerified: z.boolean().default(false),
twoFactorEnabled: z.boolean().default(false),