/** * 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 Public_Model_Users(); $user = $modelUsers->fetchWithEmail($this->_email); if (!$user instanceof Model_User) { $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID; $this->_authenticateResultInfo['messages'][] = '2Supplied credential is invalid.'; } elseif ($user->active != 'Y') { $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID; $this->_authenticateResultInfo['messages'][] = '34Supplied credential is invalid.'; } elseif ($user->type == 'ADMIN') { $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID; $this->_authenticateResultInfo['messages'][] = '34Supplied credential is invalid.'; } 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'][] = 'S4upplied credential is invalid.'; } } else { $this->_authenticateResultInfo['code'] = Zend_Auth_Result::SUCCESS; $this->_authenticateResultInfo['messages'][] = 'Authentication successful.'; } return $this->_authenticateCreateAuthResult(); }
/** * revalidate the user * * @return array */ public function revalidate() { $user = vkNgine_Auth::getIdentity(); $modelPublicUsers = new Public_Model_Users(); $dbUser = $modelPublicUsers->fetchWithEmail($user['email']); return $dbUser; }