MDL-78219 auth_lti: force empty session before launch user creation
If an existing session is active at the time of launch, that user id appears in the user_created log, incorrectly (it should be system/0). This patch makes sure that any existing session is terminated before creation of a new user during launches.
This commit is contained in:
@@ -247,6 +247,10 @@ class auth_plugin_lti extends \auth_plugin_base {
|
||||
"'{$launchdata['iss']}'. The migration claim could not be validated. A new account will be created.");
|
||||
}
|
||||
}
|
||||
// At the point of the creation, to ensure the user_created event correctly reflects the creating user of '0' (the user
|
||||
// performing the action), ensure any active session is terminated and an empty session initialised.
|
||||
$this->empty_session();
|
||||
|
||||
$user = $this->create_new_account($launchdata, $launchdata['iss']);
|
||||
$this->update_user_account($user, $launchdata, $launchdata['iss']);
|
||||
return \core_user::get_user($user->id);
|
||||
@@ -301,6 +305,17 @@ class auth_plugin_lti extends \auth_plugin_base {
|
||||
return $binduser;
|
||||
}
|
||||
|
||||
/**
|
||||
* If there's an existing session, inits an empty session.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function empty_session(): void {
|
||||
if (isloggedin()) {
|
||||
\core\session\manager::init_empty_session();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a provisioning mode is valid or not.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user