finished reset password & other changes

This commit is contained in:
2024-04-24 22:37:55 +03:00
parent b1ad7b5c3e
commit 53cadc289a
58 changed files with 1520 additions and 349 deletions

View File

@@ -1,21 +1,30 @@
import { MAX_PASSWORD_LENGTH, MIN_PASSWORD_LENGTH, PASSWORD_STRENGTH_ACME } from '@/config/validation'
import { object, string } from 'zod'
// all translations is implemented in '@/components/ui/form' via TranslateClientFragment
const minPasswordMessage = JSON.stringify(['schema.password.length.min', { min: MIN_PASSWORD_LENGTH }])
const maxPasswordMessage = JSON.stringify(['schema.password.length.max', { max: MAX_PASSWORD_LENGTH }])
const maxPasswordStrength = JSON.stringify(
['schema.password.strength.acme', { min: MIN_PASSWORD_LENGTH, max: MAX_PASSWORD_LENGTH }])
const email = string().trim().toLowerCase().email({ message: 'schema.email.required' })
const password = string().trim().regex(new RegExp(PASSWORD_STRENGTH_ACME, 'mg'),
{ message: maxPasswordStrength }).min(MIN_PASSWORD_LENGTH, { message: minPasswordMessage }).
max(MAX_PASSWORD_LENGTH, { message: maxPasswordMessage })
export const LoginSchema = object({
email: string().trim().toLowerCase().email({ message: 'schema.email.required' }),
password: string().trim().min(1, { message: 'schema.password.required' }),
email, password: string().trim().min(1, { message: 'schema.password.required' }),
})
export const RegisterSchema = object({
email: string().email({ message: 'schema.email.required' }).toLowerCase(),
password: string().trim().regex(new RegExp(PASSWORD_STRENGTH_ACME, 'mg'), { message: maxPasswordStrength }).
min(MIN_PASSWORD_LENGTH, { message: minPasswordMessage }).max(MAX_PASSWORD_LENGTH, { message: maxPasswordMessage }),
name: string().trim().min(1, { message: 'schema.name.required' }),
email, password, name: string().trim().min(1, { message: 'schema.name.required' }),
})
// Password must contain at least a single lowercase, uppercase, digit and special character.
export const ResetSchema = object({
email,
})
export const NewPasswordSchema = object({
password,
})