예제 #1
0
 /**
  * revalidates the user 
  */
 public static function revalidate()
 {
     $user = vkNgine_Auth::getIdentity();
     // revalidate the user
     $modelAdminUsers = new Admin_Model_Users();
     $dbUser = $modelAdminUsers->fetchWithEmail($user['email']);
     return $dbUser;
 }
 /**
  * authenticate() - defined by Zend_Auth_Adapter_Interface.  This method is called to
  * attempt an authentication.  Previous to this call, this adapter would have already
  * been configured with all necessary information to successfully connect to a database
  * table and attempt to find a record matching the provided identity.
  *
  * @throws Zend_Auth_Adapter_Exception if answering the authentication query is impossible
  * @return Zend_Auth_Result
  */
 public function authenticate()
 {
     $modelUsers = new Admin_Model_Users();
     $user = $modelUsers->fetchWithEmail($this->_email);
     if (!$user instanceof Model_User) {
         $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
         $this->_authenticateResultInfo['messages'][] = 'User not found';
     } elseif ($user->active != 'Y') {
         $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
         $this->_authenticateResultInfo['messages'][] = 'User is not active';
     } elseif ($user->password != md5($this->_password)) {
         if ($this->_noCredentialTreatment && $user->password == $this->_password) {
             $this->_authenticateResultInfo['code'] = Zend_Auth_Result::SUCCESS;
             $this->_authenticateResultInfo['messages'][] = 'Authentication successful.';
         } else {
             $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
             $this->_authenticateResultInfo['messages'][] = 'Password is invaild';
         }
     } else {
         $this->_authenticateResultInfo['code'] = Zend_Auth_Result::SUCCESS;
         $this->_authenticateResultInfo['messages'][] = 'Authentication successful.';
     }
     return $this->_authenticateCreateAuthResult();
 }