'User\\'], ['defaultAction' => 'view']]; 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', self::ERROR_GRACE_PERIOD_EXPIRED => 'Your membership has expired as of {expiredOn}. Please CLICK HERE to renew and then try to log in again.', ]; /** * 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]]; } elseif ('y' === $this->getData('gracePeriodExpired')) { $messages = [Qs_String::fill($this->_errorMessages[self::ERROR_GRACE_PERIOD_EXPIRED], [ 'expiredOn' => date('m/d/Y', strtotime($this->getData('expiredOn'))), 'renewUrl' => RegisterView::getPage('url') . '?' . http_build_query([ 'action' => 'renewMembership', 'userId' => $this->getData('id') ]), ])]; } 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; } }