'Admin_Login_']]; protected $_role = 'admin'; protected $_errorMessages = [ self::ERROR_INVALID_CREDENTIALS => 'Invalid Username or Password', self::ERROR_NOT_APPROVED => 'Your account is not approved yet', self::ERROR_ACCOUNT_NOT_ACTIVE => 'Your account is not active', ]; public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; } public function getSuMode() { return (bool) $this->getSessionValue('suModeEnabled'); } public function setSuMode($flag = true) { $this->setSessionValue('suModeEnabled', (bool) $flag); } /** * @param Zend_Auth_Adapter_Interface|Qs_Auth_Adapter_DbTable $adapter * @return Zend_Auth_Result */ public function authenticate(Zend_Auth_Adapter_Interface $adapter) { $result = parent::authenticate($adapter); if ($result->isValid()) { $messages = []; if (null === $this->getData('status')) { $messages = [$this->_errorMessages[self::ERROR_NOT_APPROVED]]; } elseif (App_Admin_Abstract_Obj::STATUS_ACTIVE != $this->getData('status')) { $messages = [$this->_errorMessages[self::ERROR_ACCOUNT_NOT_ACTIVE]]; } if ($messages) { $identity = $this->getIdentity(); if (isset($identity['autologinCode'])) { $adapter->clearAutologinCode($identity['autologinCode']); } $this->clearIdentity(); $result = new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, null, $messages); foreach (Zend_Session::getIterator() as $namespace) { Zend_Session::namespaceUnset($namespace); } } } else { $code = $result->getCode(); $identity = $result->getIdentity(); $messages = [$this->_errorMessages[self::ERROR_INVALID_CREDENTIALS]]; $result = new Zend_Auth_Result($code, $identity, $messages); } return $result; } }