示例#1
0
 public function testLogin()
 {
     $fixture = 'mike';
     $user = new User([], $this->usersConfigurationRepository);
     $user->login = $fixture;
     $usecase = new Login($user, $this->configuration);
     $usecase->execute();
     //
     $this->assertTrue($this->configuration->sessionRepository->getCurrentUser() instanceof User);
     //
     $returnedUser = $this->configuration->sessionRepository->getCurrentUser();
     $this->assertEquals($fixture, $returnedUser->login->getValue());
 }
示例#2
0
 protected function action()
 {
     $searchRequest = new Request();
     $searchRequest->fields = ['login' => $this->login];
     /**
      * @var User
      */
     $user = $this->configuration->usersRepository->findOne($searchRequest);
     if (empty($user)) {
         throw new NotFoundException(sprintf('User with login=`%s` not found', $this->login));
     }
     $isSamepassword = $user->password->hash($this->password) === $user->password->getValue();
     if (!$isSamepassword) {
         throw new ForbiddenException(sprintf('Password not match. %s = %s', $user->password->hash($this->password), $user->password->getValue()));
     }
     //
     $loginUsecase = new Login($user, $this->configuration);
     $loginUsecase->execute();
 }