fix: Prevent users from using the example password
This commit is contained in:
parent
22b3f0a72a
commit
6adf4afcd7
@ -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'],
|
||||||
|
@ -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'],
|
||||||
|
Loading…
Reference in New Issue
Block a user