Esempio n. 1
0
 public function testSuccess()
 {
     $this->adapter->setIdentity('test')->setCredential('test');
     $result = $this->auth->authenticate($this->adapter);
     $this->assertTrue($result->isValid());
     $this->assertEquals(Zend_Auth_Result::SUCCESS, $result->getCode());
     $this->assertTrue(is_object($this->adapter->getResultUserData()));
 }
Esempio n. 2
0
 /**
  * Login
  */
 public function loginAction()
 {
     $form = new Form_UserLogin();
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
         $auth = Zend_Auth::getInstance();
         $options = array('userIdKey' => 'userIdKey:*', 'userDataKey' => 'users:*', 'userDataIsArray' => true);
         $adapter = new Rediska_Zend_Auth_Adapter_Redis($options);
         // Set login and password
         $adapter->setIdentity($form->getElement('login')->getValue())->setCredential($form->getElement('password')->getValue());
         // Authorization
         $result = $auth->authenticate($adapter);
         if ($result->isValid()) {
             $userData = $adapter->getResultUserData();
             $session = new Zend_Session_Namespace('Zend_Auth');
             $storage = $auth->getStorage();
             $storage->write($userData);
             $this->_redirect('/post/index/');
         } else {
             $form->getElement('login')->addError('Wrong login/password combination');
         }
     }
     $this->view->form = $form;
 }