Chore/standardize password criteria (#4550)

standardize password criteria
This commit is contained in:
Henry Heng
2025-06-01 10:41:47 +01:00
committed by GitHub
parent a88337cc83
commit 63ff703e7a
8 changed files with 14 additions and 10 deletions
@@ -104,8 +104,10 @@ export const OrgSetupSchema = z
password: z
.string()
.min(8, 'Password must be at least 8 characters')
.regex(/[a-z]/, 'Password must contain at least one lowercase letter')
.regex(/[A-Z]/, 'Password must contain at least one uppercase letter')
.regex(/[!@#$%^&*]/, 'Password must contain at least one special character'),
.regex(/\d/, 'Password must contain at least one digit')
.regex(/[^a-zA-Z0-9]/, 'Password must contain at least one special character'),
confirmPassword: z.string().min(1, 'Confirm Password is required')
})
.refine((data) => data.password === data.confirmPassword, {
@@ -122,8 +124,10 @@ export const RegisterUserSchema = z
password: z
.string()
.min(8, 'Password must be at least 8 characters')
.regex(/[a-z]/, 'Password must contain at least one lowercase letter')
.regex(/[A-Z]/, 'Password must contain at least one uppercase letter')
.regex(/[!@#$%^&*]/, 'Password must contain at least one special character'),
.regex(/\d/, 'Password must contain at least one digit')
.regex(/[^a-zA-Z0-9]/, 'Password must contain at least one special character'),
confirmPassword: z.string().min(1, 'Confirm Password is required'),
token: z.string().min(1, 'Invite Code is required')
})
@@ -18,6 +18,6 @@ export function isInvalidDateTime(dateTime: unknown): boolean {
}
export function isInvalidPassword(password: unknown): boolean {
const regexPassword = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&-])[A-Za-z\d@$!%*?&-]{8,}$/
const regexPassword = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^a-zA-Z0-9]).{8,}$/
return !password || typeof password !== 'string' || !regexPassword.test(password)
}