mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-12 07:43:10 +10:00
- 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:
@ -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(
|
||||
|
||||
@ -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),
|
||||
|
||||
Reference in New Issue
Block a user