hash password in create user
This commit is contained in:
parent
016e98412b
commit
0f179e53c2
1 changed files with 11 additions and 0 deletions
|
|
@ -21,6 +21,16 @@ class CreateUser
|
|||
throw new BadRequestException('email is required');
|
||||
}
|
||||
|
||||
if ($dto->password === null) {
|
||||
throw new BadRequestException('password is required');
|
||||
}
|
||||
|
||||
if (strlen($dto->password) < 8) {
|
||||
throw new BadRequestException(
|
||||
'password must be at least 8 characters'
|
||||
);
|
||||
}
|
||||
|
||||
$email = new EmailAddress($dto->email);
|
||||
if ($this->userRepo->findByEmail($email) !== null) {
|
||||
throw new BadRequestException('email already taken');
|
||||
|
|
@ -28,6 +38,7 @@ class CreateUser
|
|||
|
||||
$this->userRepo->create(new CreateUserDto(
|
||||
email: $email,
|
||||
passwordHash: password_hash($dto->password, PASSWORD_DEFAULT),
|
||||
isAdmin: $dto->isAdmin,
|
||||
));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue