/** * * @param Gpf_Auth_Info $authInfo * @return Gpf_Data_RecordSet */ public static function getAccounts(Gpf_Auth_Info $authInfo) { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add('a.accountid', 'accountid'); $select->select->add('a.name', 'name'); $select->from->add(Gpf_Db_Table_AuthUsers::getName(), 'au'); $select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'u', 'au.authid=u.authid'); $select->from->addInnerJoin(self::getName(), 'a', 'a.accountid=u.accountid'); $select->from->addInnerJoin(Gpf_Db_Table_Roles::getName(), 'r', 'u.roleid=r.roleid'); $authInfo->addWhere($select); $select->where->add('a.rstatus', 'IN', array(Gpf_Db_Account::APPROVED, Gpf_Db_Account::SUSPENDED)); return $select->getAllRows(); }
/** * @param Gpf_Auth_Info $authInfo * @return Gpf_Auth_User */ public function load(Gpf_Auth_Info $authInfo) { Gpf_Session::getAuthUser()->setAccountId($authInfo->getAccountId()); $authData = $this->createAuthSelect($authInfo)->getOneRow(); if ($authData->get('rstatus') != Gpf_Db_User::APPROVED) { throw new Gpf_Auth_Exception($this->_("User account not approved yet")); } $authUser = $this->createUser($authData); $authUser->loadAfterAuthentication($authData); return $authUser; }
/** * * @param $username * @param $password * @param $accountId * @param $rememberMe * @return Gpf_Rpc_Form */ public function authenticateNoRpc($username = '', $password = '', $accountId = '', $rememberMe = Gpf::NO, $language = '', $roleType = '', $authToken = '') { if ($language == '') { $language = Gpf_Lang_Dictionary::getDefaultLanguage(); } $loginForm = $this->createResponseForm(); $loginForm->setField(self::USERNAME, $username); $loginForm->setField(self::PASSWORD, $password); $loginForm->setField(self::ACCOUNTID, $accountId); $loginForm->setField(self::REMEMBER_ME, $rememberMe); $loginForm->setField(self::LANGUAGE, $language); try { $authInfo = Gpf_Auth_Info::create($loginForm->getFieldValue(self::USERNAME), $loginForm->getFieldValue(self::PASSWORD), $accountId, $roleType, $authToken); if ($authInfo->hasAccount()) { return $this->authenticateUser($loginForm, $authInfo); } $accounts = Gpf_Db_Table_Accounts::getAccounts($authInfo); if ($accounts->getSize() == 0) { Gpf_Log::info($this->_sys("Wrong username/password (Username: %s)", $username)); $loginForm->setErrorMessage($this->_("Wrong username/password")); } else { if ($accounts->getSize() == 1) { $authInfo->setAccount($accounts->getRecord(0)->get('accountid')); return $this->authenticateUser($loginForm, $authInfo); } else { if ($accounts->getSize() > 1) { $loginForm->setField(self::ACCOUNTID, "select_account", $accounts->toObject()); $loginForm->setInfoMessage($this->_("Select account")); } } } } catch (Gpf_Auth_Exception $e) { $loginForm->setErrorMessage($e->getMessage()); } catch (Gpf_DbEngine_NoRowException $e) { Gpf_Log::info($this->_sys("Wrong username/password (Username: %s)", $username)); $loginForm->setErrorMessage($this->_("Wrong username/password")); } catch (Exception $e) { if (strlen($username)) { Gpf_Log::info($this->_sys("Authentication failed for user %s", $username)); } $loginForm->setErrorMessage($this->_("Authentication failed")); } return $loginForm; }
public function addWhere(Gpf_SqlBuilder_SelectBuilder $builder) { parent::addWhere($builder); $builder->where->add('au.username', '=', $this->username); $builder->where->add('au.rpassword', '=', $this->password); }
public function addWhere(Gpf_SqlBuilder_SelectBuilder $builder) { parent::addWhere($builder); $builder->where->add('au.authtoken', '=', $this->authToken); }