diff options
author | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-04-19 06:58:06 +0200 |
---|---|---|
committer | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-04-19 06:58:06 +0200 |
commit | 974f09b730acb3e1c5e770703f1536081a51a121 (patch) | |
tree | 1fb2a2a86d2eaebca7e48366a7b3e50d3f3dbe7f /lib | |
parent | d0ad8e6e695ff18a7017caae88c97bed35adf92a (diff) | |
parent | 8222ad515706d62cceb14428c959b83a69ccbc8b (diff) | |
download | nextcloud-server-974f09b730acb3e1c5e770703f1536081a51a121.tar.gz nextcloud-server-974f09b730acb3e1c5e770703f1536081a51a121.zip |
Merge pull request #24056 from owncloud/move-logout-to-logincontroller
Move logout to controller
Diffstat (limited to 'lib')
-rw-r--r-- | lib/base.php | 24 | ||||
-rw-r--r-- | lib/private/api.php | 2 | ||||
-rw-r--r-- | lib/private/appframework/http/request.php | 2 | ||||
-rw-r--r-- | lib/private/user.php | 18 | ||||
-rw-r--r-- | lib/public/irequest.php | 2 | ||||
-rw-r--r-- | lib/public/user.php | 2 |
6 files changed, 15 insertions, 35 deletions
diff --git a/lib/base.php b/lib/base.php index 27967588360..6bc0fecf04d 100644 --- a/lib/base.php +++ b/lib/base.php @@ -858,7 +858,7 @@ class OC { } } - if (!self::$CLI and (!isset($_GET["logout"]) or ($_GET["logout"] !== 'true'))) { + if (!self::$CLI) { try { if (!$systemConfig->getValue('maintenance', false) && !self::checkUpgrade(false)) { OC_App::loadApps(array('filesystem', 'logging')); @@ -897,31 +897,13 @@ class OC { return; } - // Redirect to index if the logout link is accessed without valid session - // this is needed to prevent "Token expired" messages while login if a session is expired - // @see https://github.com/owncloud/core/pull/8443#issuecomment-42425583 - if(isset($_GET['logout']) && !OC_User::isLoggedIn()) { - header("Location: " . \OC::$server->getURLGenerator()->getAbsoluteURL('/')); - return; - } - // Someone is logged in if (OC_User::isLoggedIn()) { OC_App::loadApps(); OC_User::setupBackends(); OC_Util::setupFS(); - if (isset($_GET["logout"]) and ($_GET["logout"])) { - OC_JSON::callCheck(); - if (isset($_COOKIE['oc_token'])) { - \OC::$server->getConfig()->deleteUserValue(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']); - } - OC_User::logout(); - // redirect to webroot and add slash if webroot is empty - header("Location: " . \OC::$server->getURLGenerator()->getAbsoluteURL('/')); - } else { - // Redirect to default application - OC_Util::redirectToDefaultPage(); - } + // Redirect to default application + OC_Util::redirectToDefaultPage(); } else { // Not handled and not logged in self::handleLogin(); diff --git a/lib/private/api.php b/lib/private/api.php index 12a78f1424b..bab879c95f8 100644 --- a/lib/private/api.php +++ b/lib/private/api.php @@ -179,7 +179,7 @@ class OC_API { $response = self::mergeResponses($responses); $format = self::requestedFormat(); if (self::$logoutRequired) { - OC_User::logout(); + \OC::$server->getUserSession()->logout(); } self::respond($response, $format); diff --git a/lib/private/appframework/http/request.php b/lib/private/appframework/http/request.php index c8525d1d141..7cd8cedcfdd 100644 --- a/lib/private/appframework/http/request.php +++ b/lib/private/appframework/http/request.php @@ -368,7 +368,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { /** * Shortcut for getting cookie variables * @param string $key the key that will be taken from the $_COOKIE array - * @return array the value in the $_COOKIE element + * @return string the value in the $_COOKIE element */ public function getCookie($key) { return isset($this->cookies[$key]) ? $this->cookies[$key] : null; diff --git a/lib/private/user.php b/lib/private/user.php index 26062f503d2..8767a8d5b6d 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -268,15 +268,6 @@ class OC_User { } /** - * Logs the current user out and kills all the session data - * - * Logout, destroys session - */ - public static function logout() { - self::getUserSession()->logout(); - } - - /** * Tries to login the user with HTTP Basic Authentication */ public static function tryBasicAuthLogin() { @@ -342,7 +333,14 @@ class OC_User { return $backend->getLogoutAttribute(); } - return 'href="' . link_to('', 'index.php') . '?logout=true&requesttoken=' . urlencode(\OCP\Util::callRegister()) . '"'; + $logoutUrl = \OC::$server->getURLGenerator()->linkToRouteAbsolute( + 'core.login.logout', + [ + 'requesttoken' => \OCP\Util::callRegister(), + ] + ); + + return 'href="'.$logoutUrl.'"'; } /** diff --git a/lib/public/irequest.php b/lib/public/irequest.php index a0040aa464d..296c70f4ecc 100644 --- a/lib/public/irequest.php +++ b/lib/public/irequest.php @@ -129,7 +129,7 @@ interface IRequest { * Shortcut for getting cookie variables * * @param string $key the key that will be taken from the $_COOKIE array - * @return array the value in the $_COOKIE element + * @return string the value in the $_COOKIE element * @since 6.0.0 */ public function getCookie($key); diff --git a/lib/public/user.php b/lib/public/user.php index 825e77aef6d..64ac92d2100 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -119,7 +119,7 @@ class User { * @since 5.0.0 */ public static function logout() { - \OC_User::logout(); + \OC::$server->getUserSession()->logout(); } /** |