From e7fcae9d43363dc22ba8e3bd24f3b0476dba3266 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 3 Jul 2012 16:33:15 +0200 Subject: [PATCH] Adding additional parameter `$hideSession` to SessionHandler::changeUser() When set to true the user-change is not reflected in the database. --- .../system/session/SessionHandler.class.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index 23c1818358..4ba79d24bc 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -463,11 +463,12 @@ class SessionHandler extends SingletonFactory { * logged in, after the login his old session is used to store his full data. * * @param User $user + * @param boolean $hideSession When set to true the database will not be updated. */ - public function changeUser(User $user) { + public function changeUser(User $user, $hideSession = false) { $sessionTable = call_user_func(array($this->sessionClassName, 'getDatabaseTableName')); - if ($user->userID) { + if ($user->userID && !$hideSession) { // user is not a guest, delete all other sessions of this user $sql = "DELETE FROM ".$sessionTable." WHERE sessionID <> ? @@ -479,12 +480,14 @@ class SessionHandler extends SingletonFactory { // update user reference $this->user = $user; - // update session - $sessionEditor = new $this->sessionEditorClassName($this->session); - $sessionEditor->update(array( - 'userID' => $this->user->userID, - 'username' => $this->user->username - )); + if (!$hideSession) { + // update session + $sessionEditor = new $this->sessionEditorClassName($this->session); + $sessionEditor->update(array( + 'userID' => $this->user->userID, + 'username' => $this->user->username + )); + } // reset caches $this->groupData = null; -- 2.20.1