Example #1
0
 /**
  * Reset a user's password
  *
  * @param string $email
  * @param string $password
  * @param string $code
  * @return User;
  */
 public function reset($email, $password, $code)
 {
     if ($this->check($email, $code)) {
         $user = $this->findUserByEmail(Email::fromNative($email));
         $password = $this->hasher->hash(new Password($password));
         $user->resetPassword($password);
         $this->users->update($user);
         $this->reminders->deleteReminderByCode(ReminderCode::fromNative($code));
         return $user;
     }
     throw new InvalidValueException("{$code} is not a valid reminder code");
 }
 /**
  * Register a new User
  *
  * @param string $email
  * @param string $username
  * @param string $password
  * @return void
  */
 public function register($email, $username, $password)
 {
     $email = new Email($email);
     $username = new Username($username);
     $password = new Password($password);
     $this->checkEmailIsUnique($email);
     $this->checkUsernameIsUnique($username);
     $id = $this->userRepository->nextIdentity();
     $password = $this->hashingService->hash($password);
     $user = User::register($id, $email, $username, $password);
     $this->userRepository->add($user);
     return $user;
 }