From 7f22aeb5d6779236efec72cdb6bb8703dd7c0ee1 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 21 Jun 2016 16:14:51 +0200 Subject: [PATCH] redirect to new login route (#25099) * redirect to new login route * encode anchor in url and restore it client-side --- lib/private/legacy/util.php | 11 ++++++----- settings/js/personal.js | 11 +++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index 65d00c1638..78445dab02 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -962,11 +962,12 @@ class OC_Util { public static function checkLoggedIn() { // Check if we are a user if (!OC_User::isLoggedIn()) { - header('Location: ' . \OCP\Util::linkToAbsolute('', 'index.php', - [ - 'redirect_url' => \OC::$server->getRequest()->getRequestUri() - ] - ) + header('Location: ' . \OC::$server->getURLGenerator()->linkToRoute( + 'core.login.showLoginForm', + [ + 'redirect_url' => urlencode(\OC::$server->getRequest()->getRequestUri()), + ] + ) ); exit(); } diff --git a/settings/js/personal.js b/settings/js/personal.js index aea2400e99..73d65034d9 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -368,6 +368,17 @@ $(document).ready(function () { collection: collection }); view.reload(); + + // 'redirect' to anchor sections + // anchors are lost on redirects (e.g. while solving the 2fa challenge) otherwise + // example: /settings/person?section=devices will result in /settings/person?#devices + if (!window.location.hash) { + var query = OC.parseQueryString(location.search); + if (query && query.section) { + OC.Util.History.replaceState({}); + window.location.hash = query.section; + } + } }); if (!OC.Encryption) {