/** * * @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; }
protected function loadAuthData(Gpf_Data_Record $data) { $this->username = $data->get("username"); $this->accountUserId = $data->get("accountuserid"); $this->authtoken = $data->get("authtoken"); $this->accountid = $data->get("accountid"); $this->roletypeid = $data->get("roletypeid"); $this->roleid = $data->get('roleid'); $this->authId = $data->get('authid'); $this->firstname = $data->get('firstname'); $this->lastname = $data->get('lastname'); $this->ip = $data->get('ip'); $attributes = Gpf_Db_Table_UserAttributes::getInstance(); $attributes->loadAttributes($this->accountUserId); $this->setLanguage($attributes->getAttributeWithDefaultValue(self::LANGUAGE_ATTRIBUTE_NAME, Gpf_Lang_Dictionary::getDefaultLanguage())); }
private static function setDefaultLanguageToAffiliate($accountUserId) { $attribute = new Gpf_Db_UserAttribute(); $attribute->setName(Gpf_Auth_User::LANGUAGE_ATTRIBUTE_NAME); $attribute->setAccountUserId($accountUserId); try { $attribute->loadFromData(array(Gpf_Db_Table_UserAttributes::NAME, Gpf_Db_Table_UserAttributes::ACCOUNT_USER_ID)); return; } catch (Gpf_DbEngine_NoRowException $e) { $attribute->set(Gpf_Db_Table_UserAttributes::VALUE, Gpf_Lang_Dictionary::getDefaultLanguage()); $attribute->save(); } }