Implemented email verification
This commit is contained in:
@@ -1,26 +1,21 @@
|
||||
import { MIN_PASSWORD_LENGTH } from '@/config/validation'
|
||||
import { MAX_PASSWORD_LENGTH, MIN_PASSWORD_LENGTH, PASSWORD_STRENGTH_ACME } from '@/config/validation'
|
||||
import { object, string } from 'zod'
|
||||
|
||||
const passwordMessage = JSON.stringify(
|
||||
['schema.message.password_min', { min: MIN_PASSWORD_LENGTH }])
|
||||
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 }])
|
||||
|
||||
export const LoginSchema = object({
|
||||
email: string().
|
||||
trim().
|
||||
email({ message: 'schema.message.email_required' }).
|
||||
toLowerCase(),
|
||||
password: string().
|
||||
trim().
|
||||
min(1, { message: 'schema.message.password_required' }),
|
||||
email: string().trim().toLowerCase().email({ message: 'schema.email.required' }),
|
||||
password: string().trim().min(1, { message: 'schema.password.required' }),
|
||||
})
|
||||
|
||||
export const RegisterSchema = object({
|
||||
email: string().
|
||||
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({ message: 'schema.message.email_required' }).
|
||||
toLowerCase(),
|
||||
password: string().
|
||||
trim().
|
||||
min(MIN_PASSWORD_LENGTH, { message: passwordMessage }),
|
||||
name: string().trim().min(1, { message: 'schema.message.name_required' }),
|
||||
})
|
||||
// Password must contain at least a single lowercase, uppercase, digit and special character.
|
||||
Reference in New Issue
Block a user