{"action":"created","comment":{"url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/pulls/comments/87202067","pull_request_review_id":7822398,"id":87202067,"diff_hunk":"@@ -192,14 +218,48 @@\n       /* this triplication of the dependencies is error prone and i\n        * don't see a reason for it. It would be nice to eliminate this\n        * eventually - francesco 2016-10 */\n-      return new UserManagementAuthService(\n+      var service = new UserManagementAuthService(\n         options,\n         restangular,\n         $log,\n         $q,\n         $rootScope,\n-        $window\n+        $window,\n+        EHA_USER_MANAGEMENT_AUTH_UNAUTHORISED_EVENT,\n+        EHA_USER_MANAGEMENT_AUTH_UNAUTHENTICATED_EVENT\n       );\n+\n+      function authorisationPolicy (f) {\n+        return function (policyArgument) {\n+          service\n+            .getCurrentUser()\n+            .then(function (user) {\n+              var authorised = f(user, policyArgument)\n+              if (authorised) {\n+                return p;\n+              } else {\n+                service.trigger(EHA_USER_MANAGEMENT_AUTH_UNAUTHORISED_EVENT);\n+                return $q.reject(EHA_USER_MANAGEMENT_AUTH_UNAUTHORISED_EVENT);\n+              }\n+            })\n+        }\n+      }\n+\n+      /* used in the call centre - francesco 11-2016 */\n+      service.requireUserWithAnyRole = authorisationPolicy(function (user, roles) {\n+        return roles.forEach(function (authorised, role) {\n+          return authorised || user.hasRole(role);\n+        }, false);\n+      })\n+\n+      /* used in the call centre - francesco 11-2016 */\n+      service.anyRoleExcept = authorisationPolicy(function (user, exclude) {\n+        return options.userRoles.forEach(function (authorised, role) {\n+          return authorised || (role !== exclude && user.hasRole(role));\n+        }, false);\n+      })","path":"src/auth.service.js","position":176,"original_position":176,"commit_id":"31c8deb348735389532acb7fe9253be1a14e014c","original_commit_id":"31c8deb348735389532acb7fe9253be1a14e014c","user":{"login":"danse","id":885935,"avatar_url":"https://avatars.githubusercontent.com/u/885935?v=3","gravatar_id":"","url":"https://api.github.com/users/danse","html_url":"https://github.com/danse","followers_url":"https://api.github.com/users/danse/followers","following_url":"https://api.github.com/users/danse/following{/other_user}","gists_url":"https://api.github.com/users/danse/gists{/gist_id}","starred_url":"https://api.github.com/users/danse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danse/subscriptions","organizations_url":"https://api.github.com/users/danse/orgs","repos_url":"https://api.github.com/users/danse/repos","events_url":"https://api.github.com/users/danse/events{/privacy}","received_events_url":"https://api.github.com/users/danse/received_events","type":"User","site_admin":false},"body":"but you are right, this should be a `reduce`","created_at":"2016-11-09T14:30:31Z","updated_at":"2016-11-09T14:30:31Z","html_url":"https://github.com/eHealthAfrica/angular-eha.user-management-auth/pull/9#discussion_r87202067","pull_request_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/pulls/comments/87202067"},"html":{"href":"https://github.com/eHealthAfrica/angular-eha.user-management-auth/pull/9#discussion_r87202067"},"pull_request":{"href":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/pulls/9","id":92202759,"html_url":"https://github.com/eHealthAfrica/angular-eha.user-management-auth/pull/9","diff_url":"https://github.com/eHealthAfrica/angular-eha.user-management-auth/pull/9.diff","patch_url":"https://github.com/eHealthAfrica/angular-eha.user-management-auth/pull/9.patch","issue_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/issues/9","number":9,"state":"open","locked":false,"title":"New functionality useful to integrate with the call centre","user":{"login":"danse","id":885935,"avatar_url":"https://avatars.githubusercontent.com/u/885935?v=3","gravatar_id":"","url":"https://api.github.com/users/danse","html_url":"https://github.com/danse","followers_url":"https://api.github.com/users/danse/followers","following_url":"https://api.github.com/users/danse/following{/other_user}","gists_url":"https://api.github.com/users/danse/gists{/gist_id}","starred_url":"https://api.github.com/users/danse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danse/subscriptions","organizations_url":"https://api.github.com/users/danse/orgs","repos_url":"https://api.github.com/users/danse/repos","events_url":"https://api.github.com/users/danse/events{/privacy}","received_events_url":"https://api.github.com/users/danse/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-03T17:31:10Z","updated_at":"2016-11-09T14:30:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a5e92abe0b8bcd07e5c58d6f46af9772e44eb5e8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/pulls/9/commits","review_comments_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/pulls/9/comments","review_comment_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/issues/9/comments","statuses_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/statuses/31c8deb348735389532acb7fe9253be1a14e014c","head":{"label":"danse:master","ref":"master","sha":"31c8deb348735389532acb7fe9253be1a14e014c","user":{"login":"danse","id":885935,"avatar_url":"https://avatars.githubusercontent.com/u/885935?v=3","gravatar_id":"","url":"https://api.github.com/users/danse","html_url":"https://github.com/danse","followers_url":"https://api.github.com/users/danse/followers","following_url":"https://api.github.com/users/danse/following{/other_user}","gists_url":"https://api.github.com/users/danse/gists{/gist_id}","starred_url":"https://api.github.com/users/danse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danse/subscriptions","organizations_url":"https://api.github.com/users/danse/orgs","repos_url":"https://api.github.com/users/danse/repos","events_url":"https://api.github.com/users/danse/events{/privacy}","received_events_url":"https://api.github.com/users/danse/received_events","type":"User","site_admin":false},"repo":{"id":70576684,"name":"angular-eha.user-management-auth","full_name":"danse/angular-eha.user-management-auth","owner":{"login":"danse","id":885935,"avatar_url":"https://avatars.githubusercontent.com/u/885935?v=3","gravatar_id":"","url":"https://api.github.com/users/danse","html_url":"https://github.com/danse","followers_url":"https://api.github.com/users/danse/followers","following_url":"https://api.github.com/users/danse/following{/other_user}","gists_url":"https://api.github.com/users/danse/gists{/gist_id}","starred_url":"https://api.github.com/users/danse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danse/subscriptions","organizations_url":"https://api.github.com/users/danse/orgs","repos_url":"https://api.github.com/users/danse/repos","events_url":"https://api.github.com/users/danse/events{/privacy}","received_events_url":"https://api.github.com/users/danse/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danse/angular-eha.user-management-auth","description":"Angular authentication module working with the User Management Service","fork":true,"url":"https://api.github.com/repos/danse/angular-eha.user-management-auth","forks_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/forks","keys_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/teams","hooks_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/hooks","issue_events_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/issues/events{/number}","events_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/events","assignees_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/assignees{/user}","branches_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/branches{/branch}","tags_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/tags","blobs_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/git/refs{/sha}","trees_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/statuses/{sha}","languages_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/languages","stargazers_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/stargazers","contributors_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/contributors","subscribers_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/subscribers","subscription_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/subscription","commits_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/commits{/sha}","git_commits_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/git/commits{/sha}","comments_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/comments{/number}","issue_comment_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/issues/comments{/number}","contents_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/contents/{+path}","compare_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/merges","archive_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/downloads","issues_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/issues{/number}","pulls_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/pulls{/number}","milestones_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/milestones{/number}","notifications_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/labels{/name}","releases_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/releases{/id}","deployments_url":"https://api.github.com/repos/danse/angular-eha.user-management-auth/deployments","created_at":"2016-10-11T09:16:39Z","updated_at":"2016-10-11T09:16:40Z","pushed_at":"2016-11-03T17:29:56Z","git_url":"git://github.com/danse/angular-eha.user-management-auth.git","ssh_url":"git@github.com:danse/angular-eha.user-management-auth.git","clone_url":"https://github.com/danse/angular-eha.user-management-auth.git","svn_url":"https://github.com/danse/angular-eha.user-management-auth","homepage":"","size":108,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"eHealthAfrica:master","ref":"master","sha":"3df7e64accd467c26a104b4bb81e65740b54d9b0","user":{"login":"eHealthAfrica","id":3214042,"avatar_url":"https://avatars.githubusercontent.com/u/3214042?v=3","gravatar_id":"","url":"https://api.github.com/users/eHealthAfrica","html_url":"https://github.com/eHealthAfrica","followers_url":"https://api.github.com/users/eHealthAfrica/followers","following_url":"https://api.github.com/users/eHealthAfrica/following{/other_user}","gists_url":"https://api.github.com/users/eHealthAfrica/gists{/gist_id}","starred_url":"https://api.github.com/users/eHealthAfrica/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eHealthAfrica/subscriptions","organizations_url":"https://api.github.com/users/eHealthAfrica/orgs","repos_url":"https://api.github.com/users/eHealthAfrica/repos","events_url":"https://api.github.com/users/eHealthAfrica/events{/privacy}","received_events_url":"https://api.github.com/users/eHealthAfrica/received_events","type":"Organization","site_admin":false},"repo":{"id":68818462,"name":"angular-eha.user-management-auth","full_name":"eHealthAfrica/angular-eha.user-management-auth","owner":{"login":"eHealthAfrica","id":3214042,"avatar_url":"https://avatars.githubusercontent.com/u/3214042?v=3","gravatar_id":"","url":"https://api.github.com/users/eHealthAfrica","html_url":"https://github.com/eHealthAfrica","followers_url":"https://api.github.com/users/eHealthAfrica/followers","following_url":"https://api.github.com/users/eHealthAfrica/following{/other_user}","gists_url":"https://api.github.com/users/eHealthAfrica/gists{/gist_id}","starred_url":"https://api.github.com/users/eHealthAfrica/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eHealthAfrica/subscriptions","organizations_url":"https://api.github.com/users/eHealthAfrica/orgs","repos_url":"https://api.github.com/users/eHealthAfrica/repos","events_url":"https://api.github.com/users/eHealthAfrica/events{/privacy}","received_events_url":"https://api.github.com/users/eHealthAfrica/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eHealthAfrica/angular-eha.user-management-auth","description":"Angular authentication module working with the User Management Service","fork":false,"url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth","forks_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/forks","keys_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/teams","hooks_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/hooks","issue_events_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/issues/events{/number}","events_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/events","assignees_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/assignees{/user}","branches_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/branches{/branch}","tags_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/tags","blobs_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/git/refs{/sha}","trees_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/statuses/{sha}","languages_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/languages","stargazers_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/stargazers","contributors_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/contributors","subscribers_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/subscribers","subscription_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/subscription","commits_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/commits{/sha}","git_commits_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/git/commits{/sha}","comments_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/comments{/number}","issue_comment_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/issues/comments{/number}","contents_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/contents/{+path}","compare_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/merges","archive_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/downloads","issues_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/issues{/number}","pulls_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/pulls{/number}","milestones_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/milestones{/number}","notifications_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/labels{/name}","releases_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/releases{/id}","deployments_url":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/deployments","created_at":"2016-09-21T13:16:05Z","updated_at":"2016-10-07T10:47:09Z","pushed_at":"2016-11-03T17:31:10Z","git_url":"git://github.com/eHealthAfrica/angular-eha.user-management-auth.git","ssh_url":"git@github.com:eHealthAfrica/angular-eha.user-management-auth.git","clone_url":"https://github.com/eHealthAfrica/angular-eha.user-management-auth.git","svn_url":"https://github.com/eHealthAfrica/angular-eha.user-management-auth","homepage":"","size":105,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/pulls/9"},"html":{"href":"https://github.com/eHealthAfrica/angular-eha.user-management-auth/pull/9"},"issue":{"href":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/issues/9"},"comments":{"href":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/eHealthAfrica/angular-eha.user-management-auth/statuses/31c8deb348735389532acb7fe9253be1a14e014c"}}}}
{"actor":{"display_login":"danse"}}