コード例 #1
0
 /**
  * @param SignInUserRequest $request
  *
  * @return User
  *
  * @throws UserAlreadyExistsException
  */
 public function execute($request = null)
 {
     $email = $request->email();
     $password = $request->password();
     $user = $this->userRepository->ofEmail($email);
     if (null !== $user) {
         throw new UserAlreadyExistsException();
     }
     $user = new User($this->userRepository->nextIdentity(), $email, $password);
     $this->userRepository->add($user);
     return $user;
 }
コード例 #2
0
 public function authenticate($email, $password)
 {
     DomainEventPublisher::instance()->publish(new LogInAttempted($email));
     if ($this->isAlreadyAuthenticated()) {
         return true;
     }
     $user = $this->repository->ofEmail($email);
     if (!$user) {
         return false;
     }
     if ($user->password() !== $password) {
         return false;
     }
     $this->persistAuthentication($user);
     return true;
 }