feat: add JWT authentication
This commit is contained in:
21
backend/src/domain/dtos/auth/register-user.dto.ts
Normal file
21
backend/src/domain/dtos/auth/register-user.dto.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
export class RegisterUserDto {
|
||||
private constructor(
|
||||
public readonly name: string,
|
||||
public readonly email: string,
|
||||
public readonly password: string,
|
||||
) {}
|
||||
|
||||
static create(props: { [key: string]: any }): [string | undefined, RegisterUserDto?] {
|
||||
const { name, email, password } = props;
|
||||
|
||||
if (!name) return ['name is required'];
|
||||
if (!email) return ['email is required'];
|
||||
if (!password) return ['password is required'];
|
||||
|
||||
if (password.length < 6) {
|
||||
return ['password must be at least 6 characters'];
|
||||
}
|
||||
|
||||
return [undefined, new RegisterUserDto(name, email, password)];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user