| @@ 24-60 (lines=37) @@ | ||
| 21 | * |
|
| 22 | * @author Beñat Espiña <[email protected]> |
|
| 23 | */ |
|
| 24 | class ResendInvitationUserHandler |
|
| 25 | { |
|
| 26 | /** |
|
| 27 | * The user repository. |
|
| 28 | * |
|
| 29 | * @var UserRepository |
|
| 30 | */ |
|
| 31 | private $repository; |
|
| 32 | ||
| 33 | /** |
|
| 34 | * Constructor. |
|
| 35 | * |
|
| 36 | * @param UserRepository $aRepository The user repository |
|
| 37 | */ |
|
| 38 | public function __construct(UserRepository $aRepository) |
|
| 39 | { |
|
| 40 | $this->repository = $aRepository; |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * Handles the given command. |
|
| 45 | * |
|
| 46 | * @param ResendInvitationUserCommand $aCommand The command |
|
| 47 | * |
|
| 48 | * @throws UserDoesNotExistException when the user does not exist |
|
| 49 | */ |
|
| 50 | public function __invoke(ResendInvitationUserCommand $aCommand) |
|
| 51 | { |
|
| 52 | $user = $this->repository->userOfEmail(new UserEmail($aCommand->email())); |
|
| 53 | if (null === $user) { |
|
| 54 | throw new UserDoesNotExistException(); |
|
| 55 | } |
|
| 56 | $user->regenerateInvitationToken(); |
|
| 57 | ||
| 58 | $this->repository->persist($user); |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||
| @@ 25-63 (lines=39) @@ | ||
| 22 | * @author Beñat Espiña <[email protected]> |
|
| 23 | * @author Gorka Laucirica <[email protected]> |
|
| 24 | */ |
|
| 25 | class RequestRememberPasswordHandler |
|
| 26 | { |
|
| 27 | /** |
|
| 28 | * The user repository. |
|
| 29 | * |
|
| 30 | * @var UserRepository |
|
| 31 | */ |
|
| 32 | private $repository; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Constructor. |
|
| 36 | * |
|
| 37 | * @param UserRepository $aRepository The user repository |
|
| 38 | */ |
|
| 39 | public function __construct(UserRepository $aRepository) |
|
| 40 | { |
|
| 41 | $this->repository = $aRepository; |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * Handles the given command. |
|
| 46 | * |
|
| 47 | * @param RequestRememberPasswordCommand $aCommand The command |
|
| 48 | * |
|
| 49 | * @throws UserDoesNotExistException when the user does not exist |
|
| 50 | */ |
|
| 51 | public function __invoke(RequestRememberPasswordCommand $aCommand) |
|
| 52 | { |
|
| 53 | $user = $this->repository->userOfEmail( |
|
| 54 | new UserEmail($aCommand->email()) |
|
| 55 | ); |
|
| 56 | if (null === $user) { |
|
| 57 | throw new UserDoesNotExistException(); |
|
| 58 | } |
|
| 59 | $user->rememberPassword(); |
|
| 60 | ||
| 61 | $this->repository->persist($user); |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||