Exemplo n.º 1
0
 /**
  * @param string $userId
  * @return \Lw\Domain\Model\User\User
  * @throws UserDoesNotExistException
  */
 protected function getUser($userId)
 {
     $user = $this->userRepository->ofId(new UserId($userId));
     if (null === $user) {
         throw new UserDoesNotExistException();
     }
     return $user;
 }
 /**
  * @param int $userId
  * @return int
  * @throws UserDoesNotExistException
  */
 public function execute($userId)
 {
     $user = $this->userRepository->userOfId(new UserId($userId));
     if (null === $user) {
         throw new UserDoesNotExistException();
     }
     return $user->grantWishes();
 }
Exemplo n.º 3
0
 /**
  * @param SignInUserRequest $request
  * @return User
  * @throws UserAlreadyExistsException
  */
 public function execute($request = null)
 {
     $email = $request->email();
     $password = $request->password();
     $user = $this->userRepository->userOfEmail($email);
     if (null !== $user) {
         throw new UserAlreadyExistsException();
     }
     $user = $this->userFactory->build($this->userRepository->nextIdentity(), $email, $password);
     $this->userRepository->persist($user);
     return $user;
 }
Exemplo n.º 4
0
 public function authenticate($email, $password)
 {
     if ($this->isAlreadyAuthenticated()) {
         return true;
     }
     $user = $this->repository->userOfEmail($email);
     if (!$user) {
         return false;
     }
     if ($user->password() !== $password) {
         return false;
     }
     $this->persistAuthentication($user);
     return true;
 }
Exemplo n.º 5
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;
 }
 /**
  * @test
  */
 public function afterUserSignUpItShouldBeInTheRepository()
 {
     $user = $this->executeSignIn();
     $this->assertSame($user, $this->userRepository->userOfId($user->id()));
 }
 /**
  * @test
  */
 public function afterUserSignUpItShouldBeInTheRepository()
 {
     $user = $this->executeSignIn();
     $this->assertNotNull($this->userRepository->ofId(new UserId($user['id'])));
 }