reject duplicate email in create user
This commit is contained in:
parent
30b8cc2c74
commit
96ad78425f
1 changed files with 6 additions and 1 deletions
|
|
@ -21,8 +21,13 @@ class CreateUser
|
|||
throw new BadRequestException('email is required');
|
||||
}
|
||||
|
||||
$email = new EmailAddress($dto->email);
|
||||
if ($this->userRepo->findByEmail($email) !== null) {
|
||||
throw new BadRequestException('email already taken');
|
||||
}
|
||||
|
||||
$this->userRepo->create(new CreateUserDto(
|
||||
email: new EmailAddress($dto->email),
|
||||
email: $email,
|
||||
isAdmin: $dto->isAdmin,
|
||||
));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue