From 48269143d52a07c76628bb9d07bef9bbe808a0c7 Mon Sep 17 00:00:00 2001 From: Justin Neville Date: Sun, 18 Sep 2022 09:31:06 +0100 Subject: [PATCH] Redirect to a return URL if one is present on the querystring when logging into the back office --- src/Umbraco.Web.UI.Client/src/init.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/init.js b/src/Umbraco.Web.UI.Client/src/init.js index 1f8a29ee2f..918f3377ae 100644 --- a/src/Umbraco.Web.UI.Client/src/init.js +++ b/src/Umbraco.Web.UI.Client/src/init.js @@ -119,8 +119,15 @@ app.run(['$rootScope', '$route', '$location', '$cookies', 'urlHelper', 'appState event.preventDefault(); var returnPath = null; if (rejection.path == "/login" || rejection.path.startsWith("/login/")) { + // Check if a ReturnUrl is present on the querystring and redirect to it if set + var queryStrings = urlHelper.getQueryStringParams(); + if (typeof queryStrings.ReturnUrl !== 'undefined' && queryStrings.ReturnUrl.length > 0) { + returnPath = queryStrings.ReturnUrl; + } + else { //Set the current path before redirecting so we know where to redirect back to - returnPath = encodeURIComponent(window.location.href.replace(window.location.origin,'')); + returnPath = encodeURIComponent(window.location.href.replace(window.location.origin, '')); + } } $location.path(rejection.path) if (returnPath) {