Exemplo n.º 1
0
 public static function login($username, $password, $user, $countLogin)
 {
     if (GO::modules()->chat && $countLogin && isset($_SERVER['HTTP_HOST'])) {
         $enc = \GO\Base\Util\Crypt::encrypt($password);
         if (!$enc) {
             trigger_error("Chat password encryption failed!", E_USER_NOTICE);
         }
         GO::session()->values['chat']['p'] = $enc;
     }
 }
Exemplo n.º 2
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));
 }
Exemplo n.º 3
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));
 }
Exemplo n.º 4
0
 protected function beforeSave()
 {
     if ($this->isModified('password')) {
         $decrypted = \GO\Base\Util\Crypt::decrypt($this->getOldAttributeValue('password'));
         if ($decrypted == $this->password) {
             $this->resetAttribute('password');
         } else {
             $encrypted = \GO\Base\Util\Crypt::encrypt($this->password);
             if ($encrypted) {
                 $this->password = $encrypted;
                 $this->password_encrypted = 2;
                 //deprecated. remove when email is mvc style.
             }
         }
         unset(GO::session()->values['emailModule']['accountPasswords'][$this->id]);
     }
     //		if (!empty($this->id) && !empty(GO::session()->values['emailModule']['accountPasswords'][$this->id]))
     //			unset(GO::session()->values['emailModule']['accountPasswords'][$this->id]);
     if ($this->isModified('smtp_password')) {
         $encrypted = \GO\Base\Util\Crypt::encrypt($this->smtp_password);
         if ($encrypted) {
             $this->smtp_password = $encrypted;
         }
     }
     if (($this->isNew || $this->isModified("host") || $this->isModified("port") || $this->isModified("username") || $this->isModified("password")) && $this->checkImapConnectionOnSave) {
         $imap = $this->openImapConnection();
         $this->mbroot = $imap->check_mbroot($this->mbroot);
         $this->_createDefaultFolder('sent');
         $this->_createDefaultFolder('trash');
         //	$this->_createDefaultFolder('spam');
         $this->_createDefaultFolder('drafts');
     }
     if (empty($this->store_password)) {
         $this->_session_password = $this->password;
         $this->password = '';
         $this->password_encrypted = 0;
     }
     if (empty($this->store_smtp_password)) {
         $this->_session_smtp_password = $this->smtp_password;
         $this->smtp_password = '';
     }
     return parent::beforeSave();
 }
Exemplo n.º 5
0
 protected function beforeSave()
 {
     if (!empty($this->userInputPassword1)) {
         $this->password = crypt($this->userInputPassword1);
         $encrypted = Crypt::encrypt($this->content, $this->userInputPassword1);
         if ($encrypted === false) {
             throw new \Exception("Could not encrypt note. Is mcrypt for php installed?");
         }
         $this->content = $encrypted;
     } else {
         $this->password = "";
     }
     return parent::beforeSave();
 }
Exemplo n.º 6
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();
     }
 }
Exemplo n.º 7
0
 public function formatFormInput($key, &$attributes, \GO\Customfields\Model\AbstractCustomFieldsRecord $model)
 {
     return \GO\Base\Util\Crypt::encrypt($attributes[$key]);
 }