diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2014-07-19 10:37:14 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2014-07-19 10:37:14 +0200 |
commit | bab5de8e8f3e055e6e4f03b5826d1c013b4c2e20 (patch) | |
tree | 8e653edac297dc7910d43cea7fac0c7a9a32004d /lib/private | |
parent | acf80ba7cc936b32ea5183311d0e7db4838d3705 (diff) | |
parent | 34cb09b777916319d69dd5834518ae7d8d783b41 (diff) | |
download | nextcloud-server-bab5de8e8f3e055e6e4f03b5826d1c013b4c2e20.tar.gz nextcloud-server-bab5de8e8f3e055e6e4f03b5826d1c013b4c2e20.zip |
Merge pull request #9706 from owncloud/keep_session_in_sync_stable7
keep session in sync
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/user/session.php | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/lib/private/user/session.php b/lib/private/user/session.php index 8c9b3e264e3..3e0d7ab5967 100644 --- a/lib/private/user/session.php +++ b/lib/private/user/session.php @@ -89,9 +89,9 @@ class Session implements IUserSession, Emitter { */ public function setUser($user) { if (is_null($user)) { - $this->session->remove('user_id'); + $this->getSession()->remove('user_id'); } else { - $this->session->set('user_id', $user->getUID()); + $this->getSession()->set('user_id', $user->getUID()); } $this->activeUser = $user; } @@ -105,7 +105,7 @@ class Session implements IUserSession, Emitter { if ($this->activeUser) { return $this->activeUser; } else { - $uid = $this->session->get('user_id'); + $uid = $this->getSession()->get('user_id'); if ($uid) { $this->activeUser = $this->manager->get($uid); return $this->activeUser; @@ -122,9 +122,9 @@ class Session implements IUserSession, Emitter { */ public function setLoginName($loginName) { if (is_null($loginName)) { - $this->session->remove('loginname'); + $this->getSession()->remove('loginname'); } else { - $this->session->set('loginname', $loginName); + $this->getSession()->set('loginname', $loginName); } } @@ -135,12 +135,12 @@ class Session implements IUserSession, Emitter { */ public function getLoginName() { if ($this->activeUser) { - return $this->session->get('loginname'); + return $this->getSession()->get('loginname'); } else { - $uid = $this->session->get('user_id'); + $uid = $this->getSession()->get('user_id'); if ($uid) { $this->activeUser = $this->manager->get($uid); - return $this->session->get('loginname'); + return $this->getSession()->get('loginname'); } else { return null; } @@ -246,4 +246,21 @@ class Session implements IUserSession, Emitter { setcookie('oc_token', '', time()-3600, \OC::$WEBROOT . '/'); setcookie('oc_remember_login', '', time()-3600, \OC::$WEBROOT . '/'); } + + /** + * will keep the session instance in sync with \OC::$session + * @return \OC\Session\Session + */ + private function getSession() { + //keep $this->session in sync with \OC::$session + if ($this->session !== \OC::$session) { + \OC::$server->getLogger()->debug( + '\OC::$session has been replaced with a new instance. '. + 'Closing and replacing session in UserSession instance.' + ); + $this->session->close(); + $this->session = \OC::$session; + } + return $this->session; + } } |