| @@ 14-44 (lines=31) @@ | ||
| 11 | use HMLB\UserBundle\User\UserRepository; |
|
| 12 | use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; |
|
| 13 | ||
| 14 | class ChangePasswordHandler implements Handler |
|
| 15 | { |
|
| 16 | /** |
|
| 17 | * @var UserRepository |
|
| 18 | */ |
|
| 19 | private $userRepository; |
|
| 20 | /** |
|
| 21 | * @var UserPasswordEncoderInterface |
|
| 22 | */ |
|
| 23 | private $encoder; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * @param UserRepository $userRepository |
|
| 27 | * @param UserPasswordEncoderInterface $encoder |
|
| 28 | */ |
|
| 29 | public function __construct(UserRepository $userRepository, UserPasswordEncoderInterface $encoder) |
|
| 30 | { |
|
| 31 | $this->userRepository = $userRepository; |
|
| 32 | $this->encoder = $encoder; |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @param Command|ChangePassword $command |
|
| 37 | */ |
|
| 38 | public function handle(Command $command) |
|
| 39 | { |
|
| 40 | /** @var User $user */ |
|
| 41 | $user = $this->userRepository->get($command->getUserId()); |
|
| 42 | $user->changePassword($command->getPassword(), $this->encoder); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||
| @@ 14-45 (lines=32) @@ | ||
| 11 | use HMLB\UserBundle\User\UserRepository; |
|
| 12 | use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; |
|
| 13 | ||
| 14 | class ResetPasswordHandler implements Handler |
|
| 15 | { |
|
| 16 | /** |
|
| 17 | * @var UserRepository |
|
| 18 | */ |
|
| 19 | private $userRepository; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @var UserPasswordEncoderInterface |
|
| 23 | */ |
|
| 24 | private $encoder; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @param UserRepository $userRepository |
|
| 28 | * @param UserPasswordEncoderInterface $encoder |
|
| 29 | */ |
|
| 30 | public function __construct(UserRepository $userRepository, UserPasswordEncoderInterface $encoder) |
|
| 31 | { |
|
| 32 | $this->userRepository = $userRepository; |
|
| 33 | $this->encoder = $encoder; |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @param Command|ResetPassword $command |
|
| 38 | */ |
|
| 39 | public function handle(Command $command) |
|
| 40 | { |
|
| 41 | /** @var User $user */ |
|
| 42 | $user = $this->userRepository->get($command->getUserId()); |
|
| 43 | $user->resetPassword($command->getResetToken(), $command->getPassword(), $this->encoder); |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||