本文整理汇总了PHP中UserAccount::LoadByUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP UserAccount::LoadByUsername方法的具体用法?PHP UserAccount::LoadByUsername怎么用?PHP UserAccount::LoadByUsername使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserAccount
的用法示例。
在下文中一共展示了UserAccount::LoadByUsername方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: btnLogin_Click
protected function btnLogin_Click($strFormId, $strControlId, $strParameter)
{
$blnError = false;
$strUsername = $this->txtUsername->Text;
$strPassword = $this->txtPassword->Text;
$objUserAccount = UserAccount::LoadByUsername($strUsername);
$errorMessage = 'Invalid username or password.';
$objHasher = new PasswordHash(8, PORTABLE_PASSWORDS);
// Check if that username exists
if (!$objUserAccount) {
$blnError = true;
$this->txtPassword->Warning = $errorMessage;
} elseif (!$objUserAccount->ActiveFlag) {
$blnError = true;
$this->txtPassword->Warning = $errorMessage;
} elseif (!$objHasher->CheckPassword(sha1($strPassword), $objUserAccount->PasswordHash)) {
$blnError = true;
$this->txtPassword->Warning = $errorMessage;
} else {
QApplication::Login($objUserAccount);
$objAssetRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 2);
$objInventoryRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 3);
$objContactsRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 4);
$objShippingRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 5);
$objReceivingRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 6);
$objReportsRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 7);
if (array_key_exists('strReferer', $_GET)) {
QApplication::Redirect($_GET['strReferer']);
} else {
if ($objAssetRoleModule->AccessFlag) {
// If the user has access to the assets module, send them there, otherwise...
QApplication::Redirect('./assets/');
} else {
if ($objInventoryRoleModule->AccessFlag) {
Qapplication::Redirect('./inventory/');
} else {
if ($objContactsRoleModule->AccessFlag) {
Qapplication::Redirect('./contacts/');
} else {
if ($objShippingRoleModule->AccessFlag) {
Qapplication::Redirect('./shipping/');
} else {
if ($objReceivingRoleModule->AccessFlag) {
Qapplication::Redirect('./receiving/');
} else {
if ($objReportsRoleModule->AccessFlag) {
Qapplication::Redirect('./reports/');
}
}
}
}
}
}
}
}
}
示例2: btnLogin_Click
protected function btnLogin_Click($strFormId, $strControlId, $strParameter)
{
if ($_SERVER['REMOTE_ADDR'] != "127.0.0.1" && substr($_SERVER['REMOTE_ADDR'], 0, 8) != "192.168.") {
$ip_array = json_decode(file_get_contents("http://192.168.1.168:8888/eBayBO/service.php?action=getClientIp"));
//file_put_contents("/tmp/xx.log", print_r($ip_array, true));
if (!in_array($_SERVER['REMOTE_ADDR'], $ip_array)) {
$blnError = true;
$this->txtUsername->Warning = QApplication::Translate('Invalid username or password.');
return 0;
}
}
$blnError = false;
$strUsername = $this->txtUsername->Text;
$strPassword = $this->txtPassword->Text;
$objUserAccount = UserAccount::LoadByUsername($strUsername);
$errorMessage = QApplication::Translate('Invalid username or password.');
// Check if that username exists
if (!$objUserAccount) {
$blnError = true;
$this->txtUsername->Warning = $errorMessage;
} elseif (!$objUserAccount->ActiveFlag) {
$blnError = true;
$this->txtUsername->Warning = $errorMessage;
} elseif (sha1($strPassword) != $objUserAccount->PasswordHash) {
$blnError = true;
$this->txtPassword->Warning = $errorMessage;
} else {
QApplication::Login($objUserAccount);
// If the user has access to the assets module, send them there. Otherwise, send them to the home module.
$objRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 2);
if ($objRoleModule->AccessFlag) {
QApplication::Redirect('./inventory/');
} else {
Qapplication::Redirect('./home/');
}
}
}
示例3: btnLogin_Click
protected function btnLogin_Click($strFormId, $strControlId, $strParameter)
{
$blnError = false;
$strUsername = $this->txtUsername->Text;
$strPassword = $this->txtPassword->Text;
$objUserAccount = UserAccount::LoadByUsername($strUsername);
$errorMessage = 'Invalid username or password.';
// Check if that username exists
if (!$objUserAccount) {
$blnError = true;
$this->txtPassword->Warning = $errorMessage;
} elseif (!$objUserAccount->ActiveFlag) {
$blnError = true;
$this->txtPassword->Warning = $errorMessage;
} elseif (!QApplication::CheckPassword(sha1($strPassword), $objUserAccount->PasswordHash)) {
$blnError = true;
$this->txtPassword->Warning = $errorMessage;
} else {
QApplication::Login($objUserAccount);
$objAssetRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 2);
$objInventoryRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 3);
$objContactsRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 4);
$objShippingRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 5);
$objReceivingRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 6);
$objReportsRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 7);
$strRedirect = '';
$intModule = null;
if (array_key_exists('strReferer', $_GET)) {
$strRedirect = $_GET['strReferer'];
} else {
if ($objAssetRoleModule->AccessFlag) {
// If the user has access to the assets module, send them there, otherwise...
$strRedirect = __SUBDIRECTORY__ . '/assets/';
$intModule = 2;
} else {
if ($objInventoryRoleModule->AccessFlag) {
$strRedirect = __SUBDIRECTORY__ . '/inventory/';
$intModule = 3;
} else {
if ($objContactsRoleModule->AccessFlag) {
$strRedirect = __SUBDIRECTORY__ . '/contacts/';
$intModule = 4;
} else {
if ($objShippingRoleModule->AccessFlag) {
$strRedirect = __SUBDIRECTORY__ . '/shipping/';
$intModule = 5;
} else {
if ($objReceivingRoleModule->AccessFlag) {
$strRedirect = __SUBDIRECTORY__ . '/receiving/';
$intModule = 6;
} else {
if ($objReportsRoleModule->AccessFlag) {
$strRedirect = __SUBDIRECTORY__ . '/reports/';
$intModule = 7;
}
}
}
}
}
}
}
QApplication::Redirect($strRedirect);
}
}