From 00989c641d0d519fd0f21dc9fd67c3506357e9db Mon Sep 17 00:00:00 2001 From: Adam Walsh Date: Fri, 6 Nov 2015 02:43:35 +1000 Subject: [PATCH] added ability to inherited load roles for child entities when logging in --- README.md | 1 + src/angular-worldskills-utils.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1f33606..c4352c6 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Define the following constants (don't forget to replace your client id): angular.module('yourApp').constant('WORLDSKILLS_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 diff --git a/src/angular-worldskills-utils.js b/src/angular-worldskills-utils.js index 6023ed0..d71bc15 100644 --- a/src/angular-worldskills-utils.js +++ b/src/angular-worldskills-utils.js @@ -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, ''); @@ -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;