/** * @param Command|ChangeEmail $command */ public function handle(Command $command) { /** @var User $user */ $user = $this->userRepository->get($command->getUser()); //No-op if email is same as existing if ($user->getEmail() == $command->getEmail()) { return; } $user->changeEmail($command->getEmail()); }
/** * {@inheritdoc} */ public function refreshUser(SecurityUserInterface $user) { if (!$this->supportsClass(get_class($user))) { throw new UnsupportedUserException(sprintf('Expected an instance of %s, but got "%s".', User::class, get_class($user))); } /* @var User $user */ try { $reloadedUser = $this->userRepository->get($user->getId()); } catch (AggregateRootNotFoundException $e) { throw new UsernameNotFoundException(sprintf('User with ID "%d" could not be reloaded.', $user->getId())); } return $reloadedUser; }
/** * @param Command|RequestPasswordReset $command */ public function handle(Command $command) { /** @var User $user */ $user = $this->userRepository->get($command->getUserId()); $user->requestPasswordReset(); }
/** * @param Command|ResetPassword $command */ public function handle(Command $command) { /** @var User $user */ $user = $this->userRepository->get($command->getUserId()); $user->resetPassword($command->getResetToken(), $command->getPassword(), $this->encoder); }
/** * @param Command|RequestEmailValidation $command */ public function handle(Command $command) { /** @var User $user */ $user = $this->userRepository->get($command->getUserId()); $user->requestEmailConfirmation(); }
/** * @param Command|ConfirmEmail $command */ public function handle(Command $command) { /** @var User $user */ $user = $this->userRepository->get($command->getUserId()); $user->confirmEmail($command->getConfirmationToken()); }