Пример #1
0
 /**
  * login action
  *
  * @return void
  */
 public function Login()
 {
     $recArr = $this->readInputRecord();
     try {
         $this->ValidateForm();
     } catch (ValidationException $e) {
         $this->processFormObjError($e->m_Errors);
         return;
     }
     // get the username and password
     $this->username = BizSystem::ClientProxy()->getFormInputs("username");
     $this->password = BizSystem::ClientProxy()->getFormInputs("password");
     global $g_BizSystem;
     $svcobj = BizSystem::getService(AUTH_SERVICE);
     $eventlog = BizSystem::getService(EVENTLOG_SERIVCE);
     try {
         if ($svcobj->authenticateUser($this->username, $this->password)) {
             // after authenticate user: 1. init profile
             $profile = $g_BizSystem->InitUserProfile($this->username);
             // after authenticate user: 2. insert login event
             $logComment = array($this->username, $_SERVER['REMOTE_ADDR']);
             $eventlog->log("LOGIN", "MSG_LOGIN_SUCCESSFUL", $logComment);
             // after authenticate user: 3. update login time in user record
             if (!$this->UpdateloginTime()) {
                 return false;
             }
             $redirectPage = APP_INDEX . $profile['roleStartpage'][0];
             $cookies = BizSystem::ClientProxy()->getFormInputs("session_timeout");
             if ($cookies) {
                 $password = $this->password;
                 $password = md5(md5($password . $this->username) . md5($profile['create_time']));
                 setcookie("SYSTEM_SESSION_USERNAME", $this->username, time() + (int) $cookies, "/");
                 setcookie("SYSTEM_SESSION_PASSWORD", $password, time() + (int) $cookies, "/");
             }
             if ($profile['roleStartpage'][0]) {
                 BizSystem::clientProxy()->ReDirectPage($redirectPage);
             } else {
                 parent::processPostAction();
             }
             return true;
         } else {
             $logComment = array($this->username, $_SERVER['REMOTE_ADDR'], $this->password);
             $eventlog->log("LOGIN", "MSG_LOGIN_FAILED", $logComment);
             $errorMessage['password'] = $this->getMessage("PASSWORD_INCORRECT");
             $errorMessage['login_status'] = $this->getMessage("LOGIN_FAILED");
             $this->processFormObjError($errorMessage);
         }
     } catch (Exception $e) {
         BizSystem::ClientProxy()->showErrorMessage($e->getMessage());
     }
 }