Skip to content

Commit

Permalink
Merge pull request #224 from TAMULib/2.x-staging
Browse files Browse the repository at this point in the history
2.x staging
  • Loading branch information
kaladay authored Dec 13, 2022
2 parents e991e33 + 6bf3e8b commit 24e6b45
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
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());

});
20 changes: 17 additions & 3 deletions app/services/userService.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,24 @@ core.service("UserService", function ($q, StorageService, User, WsApi) {

UserService.fetchUser = function () {
userEvents.notify('FETCH');

return WsApi.fetch(currentUser.getMapping().instantiate).then(function (res) {
delete sessionStorage.role;
var credentials = angular.fromJson(res.body).payload.Credentials;
currentUser.anonymous = credentials.role === appConfig.anonymousRole ? true : false;
var body = !!res && !!res.body ? angular.fromJson(res.body) : {};
var credentials = { role: !!currentUser.role ? currentUser.role : appConfig.anonymousRole };

// Only change credentials when packet structure is valid.
if (!!body && !!body.payload && !!body.payload.Credentials) {
delete sessionStorage.role;
credentials = angular.fromJson(res.body).payload.Credentials;
}

currentUser.anonymous = !credentials.role || credentials.role === appConfig.anonymousRole;

// Cannot have a token for the anonymous role.
if (currentUser.anonymous) {
StorageService.delete("token");
}

angular.extend(currentUser, credentials);
StorageService.set("role", currentUser.role);
userEvents.notify('RECEIVED');
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wvr/core",
"version": "2.2.2-rc.13",
"version": "2.2.2-rc.14",
"description": "Weaver AngularJs Core Module",
"repository": " https://github.com/TAMULib/Weaver-UI-Core.git",
"license": "MIT",
Expand Down Expand Up @@ -70,6 +70,8 @@
"verdaccio": "^5.13.3"
},
"overrides": {
"glob-stream": "^7.0.0"
"glob-stream": "^7.0.0",
"minimatch": "^3.1.2",
"qs": "^6.11.0"
}
}

0 comments on commit 24e6b45

Please sign in to comment.