/**
  * Delegate checking of user credentials to ZfcUser's onboard adapter chain
  *
  * @param  string  $username
  * @param  string  $password
  * @return boolean
  */
 public function checkUserCredentials($username, $password)
 {
     $request = new \Zend\Http\Request();
     $request->getPost()->set('identity', $username);
     $request->getPost()->set('credential', $password);
     $adapterResult = $this->authAdapter->prepareForAuthentication($request);
     if ($adapterResult instanceof \Zend\Stdlib\ResponseInterface) {
         return false;
     }
     $authResult = $this->auth->authenticate($this->authAdapter);
     if (!$authResult->isValid()) {
         $this->authAdapter->resetAdapters();
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Test prepareForAuthentication() when the returned collection contains stopped.
  *
  * @covers ZfcUser\Authentication\Adapter\AdapterChain::prepareForAuthentication
  * @expectedException ZfcUser\Exception\AuthenticationEventException
  */
 public function testPrepareForAuthenticationWithBadEventResult()
 {
     $result = $this->setUpPrepareForAuthentication();
     $result->expects($this->once())->method('stopped')->will($this->returnValue(true));
     $lastResponse = 'random-value';
     $result->expects($this->atLeastOnce())->method('last')->will($this->returnValue($lastResponse));
     $this->adapterChain->prepareForAuthentication($this->request);
 }