diff options
author | Christoph Wurst <christoph@owncloud.com> | 2016-05-03 16:35:00 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-05-11 13:36:46 +0200 |
commit | a9b500c03ba469a557ca235e69b7a72494cf6a9b (patch) | |
tree | b77556442bdb7316a8149e8cd08957170c1697e2 /lib/private | |
parent | bfed02b038664b8b99753b4fb874d652422f29bd (diff) | |
download | nextcloud-server-a9b500c03ba469a557ca235e69b7a72494cf6a9b.tar.gz nextcloud-server-a9b500c03ba469a557ca235e69b7a72494cf6a9b.zip |
catch possible SessionNotAvailableExceptions
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/User/Session.php | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index 0f191d52d43..297ebb2aaf0 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -48,6 +48,7 @@ use OCP\ISession; use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; +use OCP\Session\Exceptions\SessionNotAvailableException; /** * Class Session @@ -208,7 +209,11 @@ class Session implements IUserSession, Emitter { } protected function validateSession(IUser $user) { - $sessionId = $this->session->getId(); + try { + $sessionId = $this->session->getId(); + } catch (SessionNotAvailableException $ex) { + return; + } try { $token = $this->tokenProvider->getToken($sessionId); } catch (InvalidTokenException $ex) { @@ -394,8 +399,12 @@ class Session implements IUserSession, Emitter { $name = isset($request->server['HTTP_USER_AGENT']) ? $request->server['HTTP_USER_AGENT'] : 'unknown browser'; $loggedIn = $this->login($uid, $password); if ($loggedIn) { - $sessionId = $this->session->getId(); - $this->tokenProvider->generateToken($sessionId, $uid, $password, $name); + try { + $sessionId = $this->session->getId(); + $this->tokenProvider->generateToken($sessionId, $uid, $password, $name); + } catch (SessionNotAvailableException $ex) { + + } } return $loggedIn; } @@ -447,8 +456,12 @@ class Session implements IUserSession, Emitter { $authHeader = $request->getHeader('Authorization'); if (strpos($authHeader, 'token ') === false) { // No auth header, let's try session id - $sessionId = $this->session->getId(); - return $this->validateToken($request, $sessionId); + try { + $sessionId = $this->session->getId(); + return $this->validateToken($request, $sessionId); + } catch (SessionNotAvailableException $ex) { + return false; + } } else { $token = substr($authHeader, 6); return $this->validateToken($request, $token); @@ -496,7 +509,11 @@ class Session implements IUserSession, Emitter { $this->manager->emit('\OC\User', 'logout'); $user = $this->getUser(); if (!is_null($user)) { - $this->tokenProvider->invalidateToken($this->session->getId()); + try { + $this->tokenProvider->invalidateToken($this->session->getId()); + } catch (SessionNotAvailableException $ex) { + + } } $this->setUser(null); $this->setLoginName(null); |