コード例 #1
0
ファイル: login.php プロジェクト: heshuai64/einv2
        }
        $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/');
            }
        }
    }
}
LoginForm::Run('LoginForm', QApplication::$DocumentRoot . __SUBDIRECTORY__ . '/login.tpl.php');
?>
	
コード例 #2
0
ファイル: index.php プロジェクト: alcf/chms
            $this->txtPassword->Focus();
            $this->chkRemember->Checked = true;
        } else {
            $this->txtUsername->Focus();
        }
    }
    protected function btnLogin_Click($strFormId, $strControlId, $strParameter)
    {
        $objLogin = Login::LoadByUsernamePassword(trim(strtolower($this->txtUsername->Text)), $this->txtPassword->Text);
        if (!$objLogin || !$objLogin->IsAllowedToUseChms()) {
            $this->lblMessage->Text = 'Invalid email, username or password.';
            $this->txtUsername->Blink();
            $this->txtPassword->Blink();
            $this->txtUsername->Focus();
            return;
        }
        if ($this->chkRemember->Checked) {
            setcookie('username', $objLogin->Username, time() + 60 * 60 * 24 * 14, '/', null);
        } else {
            setcookie('username', null, 1, '/', null);
        }
        QApplication::Login($objLogin);
        if (array_key_exists('r', $_GET) && $_GET['r']) {
            QApplication::Redirect($_GET['r']);
        } else {
            QApplication::Redirect('/main/');
        }
    }
}
LoginForm::Run('LoginForm');