'user'], null, ['placeholders' => 'User\\']]; protected $_loginPageQuery = [null, ['type' => 'User\\Login\\']]; protected $_role = 'user'; protected $_errorMessages = [ self::ERROR_INVALID_CREDENTIALS => 'Invalid Email Address or Password', self::ERROR_NOT_APPROVED => 'Your account is not approved yet', self::ERROR_ACCOUNT_NOT_ACTIVE => 'Your account is not active', ]; /** * Return auth object * @return \App\User\Auth */ 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); } public function initECommerce() { if (Qs_SiteMap::getAliasByItem('ECommerce_Cart_')) { $checkoutView = new CheckoutView(); $checkoutView->unsetUserDataFromSession(); $cartObj = new CartObj(); $cartObj->setPrimaryKey($cartObj->getCartId()); $cartObj->mergeCart(); } return $this; } /** * @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 (Entity::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); if (Qs_SiteMap::getAliasByItem('ECommerce_Cart_')) { $cartObj = new CartObj(); $cartObj->clearSessionCartObject(); } 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; } }