Skip to content

Commit

Permalink
Merge pull request #175 from TAMULib/DAME-Aug-Sept-sprint-129-deep-li…
Browse files Browse the repository at this point in the history
…nking

Dame aug sept sprint 129 deep linking
  • Loading branch information
jcreel authored Sep 8, 2021
2 parents 0a0de41 + 359ea00 commit 92fdf3c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: "Setup Node"
uses: actions/setup-node@v2
with:
node-version: 6
node-version: 12

- name: "Install Node"
run: npm install
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/authenticationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ core.controller('AuthenticationController', function ($controller, $location, $s
}

if (appConfig.mockRole) {
$window.open(appConfig.authService + "/token?referrer=" + location.origin + path + "&mock=" + appConfig.mockRole, "_self");
$window.open(appConfig.authService + "/token?referrer=" + encodeURIComponent(location.origin + path + location.search) + "&mock=" + appConfig.mockRole, "_self");
} else {
$window.open(appConfig.authService + "/token?referrer=" + location.origin + path, "_self");
$window.open(appConfig.authService + "/token?referrer=" + encodeURIComponent(location.origin + path + location.search), "_self");
}

};
Expand Down
32 changes: 18 additions & 14 deletions app/services/accessControlService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
core.service("AccessControlService", function ($location, StorageService) {
core.service("AccessControlService", function ($location, StorageService, UserService) {

var AccessControlService = this;

Expand All @@ -19,22 +19,26 @@ core.service("AccessControlService", function ($location, StorageService) {

if(allowedUsers === undefined) return;

var role = StorageService.get("role");
var role;

var restrict = allowedUsers.indexOf(role) < 0;
UserService.userReady().then(function() {
UserService.getCurrentUser();
role = StorageService.get("role");
}).then(function() {
var restrict = allowedUsers.indexOf(role) < 0;

var authorizeUrl = StorageService.get("post_authorize_url");

if (role === 'ROLE_ANONYMOUS') {
StorageService.set("post_authorize_url", window.location.pathname);
$location.path("/error/401");
} else if (authorizeUrl && $location.path() !== "/error/401") {
StorageService.delete("post_authorize_url");
} else if (restrict) {
evt.preventDefault();
$location.path("/error/403");
}
var authorizeUrl = StorageService.get("post_authorize_url");

if (role === 'ROLE_ANONYMOUS') {
StorageService.set("post_authorize_url", window.location.pathname);
$location.path("/error/401");
} else if (authorizeUrl && $location.path() !== "/error/401") {
StorageService.delete("post_authorize_url");
} else if (restrict) {
evt.preventDefault();
$location.path("/error/403");
}
});
};

AccessControlService.getLastRoutePath = function () {
Expand Down

0 comments on commit 92fdf3c

Please sign in to comment.