diff --git a/app/User/UseCases/CreateUser.php b/app/User/UseCases/CreateUser.php index e2b9b55..cfec430 100644 --- a/app/User/UseCases/CreateUser.php +++ b/app/User/UseCases/CreateUser.php @@ -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, )); }