- Added `xmlchars` dependency to `pnpm-lock.yaml` for improved XML character handling. - Updated IAM Service audit plan to streamline post-deployment monitoring tasks. - Enhanced Dockerfile to prune development dependencies after build for a leaner production image. - Introduced a new encryption key configuration in the environment example for better security practices. - Refactored multiple service files to improve import organization and maintainability. - Improved error handling in seed scripts to provide more detailed logging on failures. - Updated various controllers and services to ensure consistent import statements and enhance readability. These changes aim to improve the overall functionality, security, and maintainability of the IAM Service.
57 lines
2.0 KiB
TypeScript
57 lines
2.0 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
/**
|
|
* EN: Password complexity validation
|
|
* VI: Xác thực độ phức tạp của mật khẩu
|
|
*/
|
|
const passwordComplexity = z.string()
|
|
.min(8, 'Password must be at least 8 characters / Mật khẩu phải có ít nhất 8 ký tự')
|
|
.regex(/[A-Z]/, 'Password must contain at least one uppercase letter / Mật khẩu phải chứa ít nhất một chữ cái viết hoa')
|
|
.regex(/[a-z]/, 'Password must contain at least one lowercase letter / Mật khẩu phải chứa ít nhất một chữ cái viết thường')
|
|
.regex(/[0-9]/, 'Password must contain at least one number / Mật khẩu phải chứa ít nhất một số')
|
|
.regex(/[^A-Za-z0-9]/, 'Password must contain at least one special character / Mật khẩu phải chứa ít nhất một ký tự đặc biệt');
|
|
|
|
/**
|
|
* EN: Register DTO
|
|
* VI: DTO đăng ký
|
|
*/
|
|
export const RegisterDto = z.object({
|
|
email: z.string().email('Invalid email format / Định dạng email không hợp lệ'),
|
|
password: passwordComplexity,
|
|
username: z.string().min(3).max(50).optional(),
|
|
});
|
|
|
|
export type RegisterDto = z.infer<typeof RegisterDto>;
|
|
|
|
/**
|
|
* EN: Login DTO
|
|
* VI: DTO đăng nhập
|
|
*/
|
|
export const LoginDto = z.object({
|
|
email: z.string().email('Invalid email format / Định dạng email không hợp lệ'),
|
|
password: z.string().min(1, 'Password is required / Mật khẩu là bắt buộc'),
|
|
});
|
|
|
|
export type LoginDto = z.infer<typeof LoginDto>;
|
|
|
|
/**
|
|
* EN: Refresh Token DTO
|
|
* VI: DTO refresh token
|
|
*/
|
|
export const RefreshTokenDto = z.object({
|
|
refreshToken: z.string().min(1, 'Refresh token is required / Refresh token là bắt buộc'),
|
|
});
|
|
|
|
export type RefreshTokenDto = z.infer<typeof RefreshTokenDto>;
|
|
|
|
/**
|
|
* EN: Change Password DTO
|
|
* VI: DTO đổi mật khẩu
|
|
*/
|
|
export const ChangePasswordDto = z.object({
|
|
currentPassword: z.string().min(1, 'Current password is required / Mật khẩu hiện tại là bắt buộc'),
|
|
newPassword: passwordComplexity,
|
|
});
|
|
|
|
export type ChangePasswordDto = z.infer<typeof ChangePasswordDto>;
|