Skip to content

Commit

Permalink
Issue 221: Return to Safety, results in going back to 403.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kaladay committed Dec 8, 2022
1 parent e991e33 commit 02be788
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion app/controllers/errorPageController.js
Original file line number Diff line number Diff line change
@@ -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());

});

0 comments on commit 02be788

Please sign in to comment.