From 02be78854fd046f52c945deb57fcea34736accad Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 8 Dec 2022 11:14:22 -0600 Subject: [PATCH 1/2] Issue 221: Return to Safety, results in going back to 403. This is happening because of a double redirect. When going to the `/management` page, a browser is redirected to `/management/internal-metadata`. Then the last route ends up referring to the `/management` page, which is the route path of `/management/:tab`. The `:tab` is not a valid part of the URL because the `$scope.lastRoute` is expected to be a path rather than a route. Rather than rename `lastRoute` to `lastPath`: 1. Add a comment describing this behavior. 2. Wrap the assignment in a function that changes the path if any route parts are found. --- app/controllers/errorPageController.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/app/controllers/errorPageController.js b/app/controllers/errorPageController.js index f455cd6d..02ef85be 100644 --- a/app/controllers/errorPageController.js +++ b/app/controllers/errorPageController.js @@ -1,5 +1,25 @@ core.controller("ErrorPageController", function ($scope, AccessControlService) { - $scope.lastRoute = AccessControlService.getLastRoutePath(); + $scope.getPath = function (path) { + + if (!!path && path.length > 0) { + var paths = path.split('/'); + + for (var i in paths) { + // Return to top-level when previous path contains route variables. + if (paths[i][0] === ':') { + paths = []; + break; + } + } + + return paths.join('/'); + } + + return path; + }; + + // This is actually a URL path and not a route. + $scope.lastRoute = $scope.getPath(AccessControlService.getLastRoutePath()); }); From 034d9b7ffec26c1e92d997703775159b2ea0de25 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 8 Dec 2022 11:22:48 -0600 Subject: [PATCH 2/2] Fix tabbing to align with 2-space-tab practices. --- app/controllers/errorPageController.js | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/controllers/errorPageController.js b/app/controllers/errorPageController.js index 02ef85be..908a49d9 100644 --- a/app/controllers/errorPageController.js +++ b/app/controllers/errorPageController.js @@ -1,25 +1,25 @@ core.controller("ErrorPageController", function ($scope, AccessControlService) { - $scope.getPath = function (path) { + $scope.getPath = function (path) { - if (!!path && path.length > 0) { - var paths = path.split('/'); + if (!!path && path.length > 0) { + var paths = path.split('/'); - for (var i in paths) { - // Return to top-level when previous path contains route variables. - if (paths[i][0] === ':') { - paths = []; - break; - } + for (var i in paths) { + // Return to top-level when previous path contains route variables. + if (paths[i][0] === ':') { + paths = []; + break; } - - return paths.join('/'); } - return path; - }; + return paths.join('/'); + } + + return path; + }; - // This is actually a URL path and not a route. - $scope.lastRoute = $scope.getPath(AccessControlService.getLastRoutePath()); + // This is actually a URL path and not a route. + $scope.lastRoute = $scope.getPath(AccessControlService.getLastRoutePath()); });