Пример #1
0
 /**
  * Implementacja metody z interfejsu Zend_Auth_Adapter_Interface
  * @see Zend_Auth_Adapter_Interface::authenticate()
  * @return Zend_Auth_Result
  */
 public function authenticate()
 {
     if (empty($this->_username)) {
         throw new Zend_Auth_Adapter_Exception('Nie podano loginu!');
     }
     if (empty($this->_password)) {
         throw new Zend_Auth_Adapter_Exception('Nie podano hasła!');
     }
     $config = Zend_Registry::get('config');
     $this->_options = $config['ldap'];
     $resultLDAP = parent::authenticate();
     if ($resultLDAP->isValid()) {
         $userModel = new User();
         $userRow = $userModel->fetchRow(array('login = ?' => new Zend_Db_Expr("UPPER('{$this->_username}')"), 'ghost = ?' => 'f', 'is_locked = ?' => 'f', new Zend_Db_Expr('valid_until > NOW()')));
         if ($userRow !== null) {
             $identity = $this->_toStdClass($userRow);
             unset($identity->password);
             $ldapData = parent::getAccountObject();
             $identity->ldap = $ldapData;
             $branchModel = new Branch();
             $identity->id_branch = ODDZIAL_ID;
             $identity->view_branch = ODDZIAL_ID;
             $data = $branchModel->find($identity->id_branch);
             $d = $data->current()->toArray();
             $d['application_code'] = 'getin';
             $identity->jednostka = $d;
             $identity->user_backend_apps_logins = null;
             $identity->default_branches[$d['application_code']]['default_login'] = '******';
             $this->_authResult['code'] = Zend_Auth_Result::SUCCESS;
             $this->_authResult['messages'] = 'Autoryzacja pomyślna.';
             $this->_authResult['identity'] = $identity;
             return $this->_createAuthResult();
         } else {
             $this->_authResult['code'] = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
             $this->_authResult['messages'] = 'Konto nieaktywne lub zablokowane.';
             return $this->_createAuthResult();
         }
     } else {
         $this->_authResult['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
         $this->_authResult['messages'] = 'Nieprawidłowe dane logowania.';
         return $this->_createAuthResult();
     }
 }
 public function testAccountObjectRetrievalWithOmittedAttributes()
 {
     $adapter = new Zend_Auth_Adapter_Ldap(array($this->_options), TESTS_ZEND_LDAP_ALT_USERNAME, TESTS_ZEND_LDAP_ALT_PASSWORD);
     $result = $adapter->authenticate();
     $account = $adapter->getAccountObject(array(), array('userPassword'));
     $this->assertType('stdClass', $account);
     $this->assertFalse(isset($account->userpassword));
 }