return user from create user use case
This commit is contained in:
parent
bb4e27a45b
commit
6c5833af5e
1 changed files with 3 additions and 2 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\User\UseCases;
|
namespace App\User\UseCases;
|
||||||
|
|
||||||
use App\Exceptions\BadRequestException;
|
use App\Exceptions\BadRequestException;
|
||||||
|
use App\User\User;
|
||||||
use App\User\UserRepository;
|
use App\User\UserRepository;
|
||||||
use App\ValueObjects\EmailAddress;
|
use App\ValueObjects\EmailAddress;
|
||||||
|
|
||||||
|
|
@ -15,7 +16,7 @@ class CreateUser
|
||||||
/**
|
/**
|
||||||
* @throws BadRequestException
|
* @throws BadRequestException
|
||||||
*/
|
*/
|
||||||
public function execute(CreateUserRequest $dto): void
|
public function execute(CreateUserRequest $dto): User
|
||||||
{
|
{
|
||||||
if ($dto->email === null) {
|
if ($dto->email === null) {
|
||||||
throw new BadRequestException('email is required');
|
throw new BadRequestException('email is required');
|
||||||
|
|
@ -36,7 +37,7 @@ class CreateUser
|
||||||
throw new BadRequestException('email already taken');
|
throw new BadRequestException('email already taken');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->userRepo->create(new CreateUserDto(
|
return $this->userRepo->create(new CreateUserDto(
|
||||||
email: $email,
|
email: $email,
|
||||||
passwordHash: password_hash($dto->password, PASSWORD_DEFAULT),
|
passwordHash: password_hash($dto->password, PASSWORD_DEFAULT),
|
||||||
isAdmin: $dto->isAdmin,
|
isAdmin: $dto->isAdmin,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue