|
|
@@ -1331,8 +1331,9 @@ class PluginSinglesignonProvider extends CommonDBTM {
|
|
|
|
|
|
$this->syncOAuthPhoto($user);
|
|
|
|
|
|
- //Create fake auth
|
|
|
- $auth = new Auth();
|
|
|
+ // Create fake auth
|
|
|
+ // phpcs:disable
|
|
|
+ /* $auth = new Auth();
|
|
|
$auth->user = $user;
|
|
|
$auth->auth_succeded = true;
|
|
|
$auth->extauth = 1;
|
|
|
@@ -1342,7 +1343,25 @@ class PluginSinglesignonProvider extends CommonDBTM {
|
|
|
Session::init($auth);
|
|
|
|
|
|
// Return false if the profile is not defined in Session::init($auth)
|
|
|
- return $auth->auth_succeded;
|
|
|
+ return $auth->auth_succeded; */
|
|
|
+ // phpcs:enable
|
|
|
+
|
|
|
+ global $DB;
|
|
|
+
|
|
|
+ $userId = $user->fields['id'];
|
|
|
+
|
|
|
+ // Set a random password for the current user
|
|
|
+ $tempPassword = bin2hex(random_bytes(64));
|
|
|
+ $DB->update('glpi_users', ['password' => Auth::getPasswordHash($tempPassword)], ['id' => $userId]);
|
|
|
+
|
|
|
+ // Log-in using the generated password as if you were logging in using the login form
|
|
|
+ $auth = new Auth();
|
|
|
+ $authResult = $auth->login($user->fields['name'], $tempPassword);
|
|
|
+
|
|
|
+ // Rollback password change
|
|
|
+ $DB->update('glpi_users', ['password' => $user->fields['password']], ['id' => $userId]);
|
|
|
+
|
|
|
+ return $authResult;
|
|
|
}
|
|
|
|
|
|
public function linkUser($user_id) {
|