Skip to content

Commit

Permalink
added ability to inherited load roles for child entities when logging in
Browse files Browse the repository at this point in the history
  • Loading branch information
gbervik committed Nov 5, 2015
1 parent b0a3278 commit 00989c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Define the following constants (don't forget to replace your client id):
angular.module('yourApp').constant('WORLDSKILLS_CLIENT_ID', '<your client id>');
angular.module('yourApp').constant('WORLDSKILLS_API_AUTH', 'https://api.worldskills.org/auth');
angular.module('yourApp').constant('WORLDSKILLS_AUTHORIZE_URL', 'https://auth.worldskills.org/oauth/authorize');
angular.module('yourApp').constant('LOAD_CHILD_ENTITY_ROLES', false);
```

### Authentication
Expand Down
5 changes: 3 additions & 2 deletions src/angular-worldskills-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
}
}

this.$get = ['$rootScope', '$http', '$q', 'WORLDSKILLS_CLIENT_ID', 'WORLDSKILLS_AUTHORIZE_URL', 'WORLDSKILLS_API_AUTH', function($rootScope, $http, $q, WORLDSKILLS_CLIENT_ID, WORLDSKILLS_AUTHORIZE_URL, WORLDSKILLS_API_AUTH) {
this.$get = ['$rootScope', '$http', '$q', 'WORLDSKILLS_CLIENT_ID', 'WORLDSKILLS_AUTHORIZE_URL', 'WORLDSKILLS_API_AUTH', 'LOAD_CHILD_ENTITY_ROLES', function($rootScope, $http, $q, WORLDSKILLS_CLIENT_ID, WORLDSKILLS_AUTHORIZE_URL, WORLDSKILLS_API_AUTH, LOAD_CHILD_ENTITY_ROLES) {

var appUrl = window.location.href.replace(window.location.hash, '');

Expand All @@ -125,7 +125,8 @@
};

auth.getUser = function(){
return $http({method: 'GET', url: WORLDSKILLS_API_AUTH + '/users/loggedIn'})
var userResource = LOAD_CHILD_ENTITY_ROLES ? 'logged_in_inherited_roles' : 'loggedIn';
return $http({method: 'GET', url: WORLDSKILLS_API_AUTH + '/users/' + userResource})
.success(function(data, status, headers, config) {
data.$promise = user;
auth.user = data;
Expand Down

0 comments on commit 00989c6

Please sign in to comment.