Example #1
0
 /**
  * @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());
 }
Example #2
0
 /**
  * {@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;
 }
Example #3
0
 /**
  * Adds a message trace to the message.
  *
  * @param TraceableMessage $message
  */
 private function traceMessage(TraceableMessage $message)
 {
     try {
         $user = $this->userRepository->getCurrentUser();
         $trace = Trace::user($user);
     } catch (AggregateRootNotFoundException $e) {
         if (Context::inCliContext()) {
             $trace = Trace::cli();
         } else {
             $trace = Trace::http();
         }
     }
     $message->trace($trace);
 }
 /**
  * @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);
 }
Example #6
0
 /**
  * @param Command|RegisterUser $command
  */
 public function handle(Command $command)
 {
     $user = call_user_func([$this->userClass, 'register'], $command->getUsername(), $command->getEmail(), $command->getPassword(), $this->encoder);
     $this->userRepository->add($user);
 }
 /**
  * @param Command|RequestEmailValidation $command
  */
 public function handle(Command $command)
 {
     /** @var User $user */
     $user = $this->userRepository->get($command->getUserId());
     $user->requestEmailConfirmation();
 }
Example #8
0
 /**
  * @param Command|ConfirmEmail $command
  */
 public function handle(Command $command)
 {
     /** @var User $user */
     $user = $this->userRepository->get($command->getUserId());
     $user->confirmEmail($command->getConfirmationToken());
 }