Beispiel #1
0
 /**
  * Page with a login form
  * If $siteconfig['tickets_allow_anonymous'] is set to TRUE then this page 
  * shows also a link to the "New ticket" page.
  */
 protected function actionTicketLogin()
 {
     // Create an empty user model
     $model = new \GO\Base\Model\User();
     if (\GO\Base\Util\Http::isPostRequest()) {
         // Set the posted values to the user model
         $model->username = $_POST['User']['username'];
         $password = $_POST['User']['password'];
         // Check if the login is correct, then the correct user object is returned
         $user = \GO::session()->login($model->username, $password);
         if (!$user) {
             // set the correct login failure message
             GOS::site()->notifier->setMessage('error', \GO::t('badLogin'));
         } else {
             if (!empty($_POST['rememberMe'])) {
                 // Encrypt the username for the rememberMe cookie
                 $encUsername = \GO\Base\Util\Crypt::encrypt($model->username);
                 if ($encUsername) {
                     $encUsername = $model->username;
                 }
                 // Encrypt the password for the rememberMe cookie
                 $encPassword = \GO\Base\Util\Crypt::encrypt($password);
                 if ($encPassword) {
                     $encPassword = $password;
                 }
                 // Set the rememberMe cookies
                 \GO\Base\Util\Http::setCookie('GO_UN', $encUsername);
                 \GO\Base\Util\Http::setCookie('GO_PW', $encPassword);
             }
             // Login is successfull, redirect to the ticketlist page
             $this->redirect(array('tickets/site/ticketlist'));
         }
     }
     // Render the loginselection form
     $this->render('loginSelection', array('model' => $model));
 }
Beispiel #2
0
 /**
  * Render a login page 
  */
 public function actionLogin()
 {
     $model = new \GO\Base\Model\User();
     if (\GO\Base\Util\Http::isPostRequest() && isset($_POST['User'])) {
         $model->username = $_POST['User']['username'];
         $password = $_POST['User']['password'];
         $user = \GO::session()->login($model->username, $password);
         //reset language after login
         if (!empty(\Site::model()->language)) {
             \GO::language()->setLanguage(\Site::model()->language);
         }
         if (!$user) {
             \Site::notifier()->setMessage('error', \GO::t('badLogin'));
             // set the correct login failure message
         } else {
             if (!empty($_POST['rememberMe'])) {
                 $encUsername = \GO\Base\Util\Crypt::encrypt($model->username);
                 if ($encUsername) {
                     $encUsername = $model->username;
                 }
                 $encPassword = \GO\Base\Util\Crypt::encrypt($password);
                 if ($encPassword) {
                     $encPassword = $password;
                 }
                 \GO\Base\Util\Http::setCookie('GO_UN', $encUsername);
                 \GO\Base\Util\Http::setCookie('GO_PW', $encPassword);
             }
             $this->redirect($this->getReturnUrl());
         }
     } elseif (isset($_GET['ref'])) {
         // url to go to after login
         \GO::session()->values['sites']['returnUrl'] = $_GET['ref'];
     }
     echo $this->render('login', array('model' => $model));
 }
Beispiel #3
0
 protected function actionLogin($params)
 {
     if (!empty($params["login_language"])) {
         GO::language()->setLanguage($params["login_language"]);
     }
     if (!empty($params['domain'])) {
         $params['username'] .= $params['domain'];
     }
     $response = array();
     if (!$this->fireEvent('beforelogin', array(&$params, &$response))) {
         $response['success'] = false;
         if (!isset($response['feedback'])) {
             $response['feedback'] = GO::t('badLogin');
         }
         return $response;
     }
     $user = \GO::session()->login($params['username'], $params['password']);
     $response['success'] = $user != false;
     if (!$response['success']) {
         $response['feedback'] = \GO::t('badLogin');
     } else {
         if (!empty($params['remind'])) {
             $encUsername = \GO\Base\Util\Crypt::encrypt($params['username']);
             if (!$encUsername) {
                 $encUsername = $params['username'];
             }
             $encPassword = \GO\Base\Util\Crypt::encrypt($params['password']);
             if (!$encPassword) {
                 $encPassword = $params['password'];
             }
             \GO\Base\Util\Http::setCookie('GO_UN', $encUsername);
             \GO\Base\Util\Http::setCookie('GO_PW', $encPassword);
         }
         $response['groupoffice_version'] = \GO::config()->version;
         $response['user_id'] = $user->id;
         $response['security_token'] = \GO::session()->values["security_token"];
         $response['sid'] = session_id();
         if (!empty($params['return_user_info'])) {
             $response['modules'] = array();
             foreach (\GO::modules()->getAllModules() as $module) {
                 $response['modules'][] = $module->id;
             }
             $response['user'] = \GO::user()->getAttributes();
         }
         if (!empty($params["login_language"])) {
             GO::language()->setLanguage($params["login_language"]);
             \GO::user()->language = \GO::language()->getLanguage();
             \GO::user()->save();
         }
     }
     //		return $response;
     if (\GO\Base\Util\Http::isAjaxRequest()) {
         return $response;
     } else {
         $this->redirect();
     }
 }