Skip to content

Commit

Permalink
Dev: remove deprecated code _GetSessionUserRights
Browse files Browse the repository at this point in the history
Dev: USER_RIGHT_INITIALSUPERADMIN replaced by config
Dev: and not used since 2.6lts or before
  • Loading branch information
Shnoulle committed Jan 19, 2018
1 parent a5a05d5 commit 543257f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 40 deletions.
31 changes: 0 additions & 31 deletions application/controllers/AdminController.php
Expand Up @@ -105,10 +105,6 @@ protected function _sessioncontrol()
Yii::app()->session["adminlang"] = Yii::app()->getConfig("defaultlang");
}
Yii::app()->setLanguage(Yii::app()->session["adminlang"]);

if (!empty($this->user_id)) {
$this->_GetSessionUserRights($this->user_id);
}
}

/**
Expand Down Expand Up @@ -229,32 +225,6 @@ public function getActionClasses()
);
}

/**
* Set Session User Rights
*
* @access public
* @return void
*/
public function _GetSessionUserRights($loginID)
{
$oUser = User::model()->findByPk($loginID);

// SuperAdmins
// * original superadmin with uid=1 unless manually changed and defined
// in config-defaults.php
// * or any user having USER_RIGHT_SUPERADMIN right

// Let's check if I am the Initial SuperAdmin

$oUser = User::model()->findByAttributes(array('parent_id' => 0));

if (!is_null($oUser) && $oUser->uid == $loginID) {
Yii::app()->session['USER_RIGHT_INITIALSUPERADMIN'] = 1;
} else {
Yii::app()->session['USER_RIGHT_INITIALSUPERADMIN'] = 0;
}
}

/**
* Prints Admin Header
*
Expand All @@ -273,7 +243,6 @@ public function _getAdminHeader($meta = false, $return = false)
$aData['adminlang'] = Yii::app()->language;
$aData['languageRTL'] = "";
$aData['styleRTL'] = "";

Yii::app()->loadHelper("surveytranslator");

if (getLanguageRTL(Yii::app()->language)) {
Expand Down
6 changes: 1 addition & 5 deletions application/controllers/admin/authentication.php
Expand Up @@ -169,11 +169,6 @@ public static function prepareLogin()
FailedLoginAttempt::model()->deleteAttempts();
App()->user->setState('plugin', $authMethod);

// This call to AdminController::_GetSessionUserRights() ;
// NB 1:calling another controller method from a controller method is a bad pratice
// NB 2: this function only check if logged in user is super admin to set in session USER_RIGHT_INITIALSUPERADMIN
// TODO: move this function to the user object
Yii::app()->getController()->_GetSessionUserRights(Yii::app()->session['loginID']);
Yii::app()->session['just_logged_in'] = true;
Yii::app()->session['loginsummary'] = self::getSummary();

Expand All @@ -183,6 +178,7 @@ public static function prepareLogin()
return array('success');
} else {
// Failed
tracevar("authenticate failed");
$event = new PluginEvent('afterFailedLoginAttempt');
$event->set('identity', $identity);
App()->getPluginManager()->dispatchEvent($event);
Expand Down
7 changes: 3 additions & 4 deletions application/helpers/remotecontrol/remotecontrol_handle.php
Expand Up @@ -51,9 +51,9 @@ public function get_session_key($username, $password)
$session->data = $username;
$session->save();
return $sSessionKey;
} else {
return array('status' => 'Invalid user name or password');
}
return array('status' => 'Invalid user name or password');

}

/**
Expand Down Expand Up @@ -3005,11 +3005,10 @@ protected function _jumpStartSession($username)
'adminlang' => 'en'
);
foreach ($session as $k => $v) {
Yii::app()->session[$k] = $v;
Yii::app()->session[$k] = $v;
}
Yii::app()->user->setId($aUserData['uid']);

$this->controller->_GetSessionUserRights($aUserData['uid']);
return true;
}

Expand Down

0 comments on commit 543257f

Please sign in to comment.