fix: Prevent users from using the example password

This commit is contained in:
April Hall 2025-02-16 15:05:07 -05:00
parent 22b3f0a72a
commit 6adf4afcd7
Signed by: arithefirst
GPG Key ID: 4508A15C4DB91C5B
2 changed files with 8 additions and 0 deletions

View File

@ -11,6 +11,10 @@ export const changePasswordSchema = z
.regex(/(?=.*\d)/gm, 'New password must contain at least one number.') .regex(/(?=.*\d)/gm, 'New password must contain at least one number.')
.regex(/(?=.*\W)/gm, 'New password must contain at least one special character'), .regex(/(?=.*\W)/gm, 'New password must contain at least one special character'),
}) })
.refine((schema) => schema.newPassword !== 'Password123!', {
message: "You can't use the example password, silly",
path: ['newPassword'],
})
.refine((schema) => schema.currentPassword !== schema.newPassword, { .refine((schema) => schema.currentPassword !== schema.newPassword, {
message: 'New password cannot be the same as old password.', message: 'New password cannot be the same as old password.',
path: ['newPassword'], path: ['newPassword'],

View File

@ -18,6 +18,10 @@ export const signupSchema = z
.regex(/(?=.*\W)/gm, 'Password must contain at least one special character'), .regex(/(?=.*\W)/gm, 'Password must contain at least one special character'),
verify: z.string().nonempty('Passwords do not match.'), verify: z.string().nonempty('Passwords do not match.'),
}) })
.refine((schema) => schema.password !== 'Password123!', {
message: "You can't use the example password, silly",
path: ['password'],
})
.refine((schema) => schema.verify === schema.password, { .refine((schema) => schema.verify === schema.password, {
message: "Passwords don't match", message: "Passwords don't match",
path: ['verify'], path: ['verify'],