{"action":"created","comment":{"url":"https://api.github.com/repos/adaptlearning/adapt_authoring/pulls/comments/27467900","id":27467900,"diff_hunk":"@@ -529,16 +523,57 @@ exports = module.exports = {\n             }\n           }\n \n-          roles.forEach(function (r) {\n-            r.statement.forEach(function (s, index) {\n-              s.resource = s.resource.replace('{{tenantid}}', tenantId);\n-              statements.push(s);\n-            });\n-          });\n+          if (!roles || 0 === roles.length) {\n+            return callback(null, []);\n+          }\n \n-          return callback(null, statements);\n-        });\n-      });\n+          async.each(\n+            roles,\n+            function (r, nextRole) {\n+              async.each(\n+                r.statement,\n+                function (s, nextStatement) {\n+                  s.resource = s.resource.replace('{{tenantid}}', tenantId);\n+                  statements.push(s);\n+                  nextStatement();\n+                },\n+                nextRole\n+              );\n+            },\n+            function (err) {\n+              if (err) {\n+                return callback(err);\n+              }\n+\n+              // next retrieve bare policies\n+              db.retrieve('policy', {user: userId}, function (error, records) {\n+                if (err) {\n+                  return callback(err);\n+                }\n+\n+                if (!records || 0 === records.length) {","path":"lib/permissions.js","position":69,"original_position":69,"commit_id":"7999df56d8d2fdd4b33443298292eab39de246e7","original_commit_id":"7999df56d8d2fdd4b33443298292eab39de246e7","user":{"login":"brian-learningpool","id":1327471,"avatar_url":"https://avatars.githubusercontent.com/u/1327471?v=3","gravatar_id":"","url":"https://api.github.com/users/brian-learningpool","html_url":"https://github.com/brian-learningpool","followers_url":"https://api.github.com/users/brian-learningpool/followers","following_url":"https://api.github.com/users/brian-learningpool/following{/other_user}","gists_url":"https://api.github.com/users/brian-learningpool/gists{/gist_id}","starred_url":"https://api.github.com/users/brian-learningpool/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brian-learningpool/subscriptions","organizations_url":"https://api.github.com/users/brian-learningpool/orgs","repos_url":"https://api.github.com/users/brian-learningpool/repos","events_url":"https://api.github.com/users/brian-learningpool/events{/privacy}","received_events_url":"https://api.github.com/users/brian-learningpool/received_events","type":"User","site_admin":false},"body":"I don't think there is a preferred format as such.  Some developers like to write it like this as it can sometimes accidental assignment when you really meant to compare values.","created_at":"2015-03-31T10:28:44Z","updated_at":"2015-03-31T10:28:44Z","html_url":"https://github.com/adaptlearning/adapt_authoring/pull/621#discussion_r27467900","pull_request_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/pulls/621","_links":{"self":{"href":"https://api.github.com/repos/adaptlearning/adapt_authoring/pulls/comments/27467900"},"html":{"href":"https://github.com/adaptlearning/adapt_authoring/pull/621#discussion_r27467900"},"pull_request":{"href":"https://api.github.com/repos/adaptlearning/adapt_authoring/pulls/621"}}},"pull_request":{"url":"https://api.github.com/repos/adaptlearning/adapt_authoring/pulls/621","id":32210823,"html_url":"https://github.com/adaptlearning/adapt_authoring/pull/621","diff_url":"https://github.com/adaptlearning/adapt_authoring/pull/621.diff","patch_url":"https://github.com/adaptlearning/adapt_authoring/pull/621.patch","issue_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/issues/621","number":621,"state":"open","locked":false,"title":"Ab 332 performance bottlenecks","user":{"login":"dennis-learningpool","id":1692639,"avatar_url":"https://avatars.githubusercontent.com/u/1692639?v=3","gravatar_id":"","url":"https://api.github.com/users/dennis-learningpool","html_url":"https://github.com/dennis-learningpool","followers_url":"https://api.github.com/users/dennis-learningpool/followers","following_url":"https://api.github.com/users/dennis-learningpool/following{/other_user}","gists_url":"https://api.github.com/users/dennis-learningpool/gists{/gist_id}","starred_url":"https://api.github.com/users/dennis-learningpool/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dennis-learningpool/subscriptions","organizations_url":"https://api.github.com/users/dennis-learningpool/orgs","repos_url":"https://api.github.com/users/dennis-learningpool/repos","events_url":"https://api.github.com/users/dennis-learningpool/events{/privacy}","received_events_url":"https://api.github.com/users/dennis-learningpool/received_events","type":"User","site_admin":false},"body":"* Fixes a few uses of array.forEach in endpoints\r\n* Fixes issue where an update of tenant details would be ignored by separate processes","created_at":"2015-03-30T09:38:54Z","updated_at":"2015-03-31T10:28:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"02953947b4b5bebc38346ad9b40f71bca0488a0a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/pulls/621/commits","review_comments_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/pulls/621/comments","review_comment_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/pulls/comments{/number}","comments_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/issues/621/comments","statuses_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/statuses/7999df56d8d2fdd4b33443298292eab39de246e7","head":{"label":"dennis-learningpool:AB-332-performance-bottlenecks","ref":"AB-332-performance-bottlenecks","sha":"7999df56d8d2fdd4b33443298292eab39de246e7","user":{"login":"dennis-learningpool","id":1692639,"avatar_url":"https://avatars.githubusercontent.com/u/1692639?v=3","gravatar_id":"","url":"https://api.github.com/users/dennis-learningpool","html_url":"https://github.com/dennis-learningpool","followers_url":"https://api.github.com/users/dennis-learningpool/followers","following_url":"https://api.github.com/users/dennis-learningpool/following{/other_user}","gists_url":"https://api.github.com/users/dennis-learningpool/gists{/gist_id}","starred_url":"https://api.github.com/users/dennis-learningpool/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dennis-learningpool/subscriptions","organizations_url":"https://api.github.com/users/dennis-learningpool/orgs","repos_url":"https://api.github.com/users/dennis-learningpool/repos","events_url":"https://api.github.com/users/dennis-learningpool/events{/privacy}","received_events_url":"https://api.github.com/users/dennis-learningpool/received_events","type":"User","site_admin":false},"repo":{"id":18071643,"name":"adapt_authoring","full_name":"dennis-learningpool/adapt_authoring","owner":{"login":"dennis-learningpool","id":1692639,"avatar_url":"https://avatars.githubusercontent.com/u/1692639?v=3","gravatar_id":"","url":"https://api.github.com/users/dennis-learningpool","html_url":"https://github.com/dennis-learningpool","followers_url":"https://api.github.com/users/dennis-learningpool/followers","following_url":"https://api.github.com/users/dennis-learningpool/following{/other_user}","gists_url":"https://api.github.com/users/dennis-learningpool/gists{/gist_id}","starred_url":"https://api.github.com/users/dennis-learningpool/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dennis-learningpool/subscriptions","organizations_url":"https://api.github.com/users/dennis-learningpool/orgs","repos_url":"https://api.github.com/users/dennis-learningpool/repos","events_url":"https://api.github.com/users/dennis-learningpool/events{/privacy}","received_events_url":"https://api.github.com/users/dennis-learningpool/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dennis-learningpool/adapt_authoring","description":"Source code for the Adapt Authoring tool","fork":true,"url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring","forks_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/forks","keys_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/teams","hooks_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/hooks","issue_events_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/issues/events{/number}","events_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/events","assignees_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/assignees{/user}","branches_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/branches{/branch}","tags_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/tags","blobs_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/git/refs{/sha}","trees_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/statuses/{sha}","languages_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/languages","stargazers_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/stargazers","contributors_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/contributors","subscribers_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/subscribers","subscription_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/subscription","commits_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/commits{/sha}","git_commits_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/git/commits{/sha}","comments_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/comments{/number}","issue_comment_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/issues/comments{/number}","contents_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/contents/{+path}","compare_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/merges","archive_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/downloads","issues_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/issues{/number}","pulls_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/pulls{/number}","milestones_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/milestones{/number}","notifications_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/labels{/name}","releases_url":"https://api.github.com/repos/dennis-learningpool/adapt_authoring/releases{/id}","created_at":"2014-03-24T17:33:19Z","updated_at":"2014-03-24T17:33:19Z","pushed_at":"2015-03-31T09:33:55Z","git_url":"git://github.com/dennis-learningpool/adapt_authoring.git","ssh_url":"git@github.com:dennis-learningpool/adapt_authoring.git","clone_url":"https://github.com/dennis-learningpool/adapt_authoring.git","svn_url":"https://github.com/dennis-learningpool/adapt_authoring","homepage":null,"size":38835,"stargazers_count":0,"watchers_count":0,"language":null,"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":"adaptlearning:develop","ref":"develop","sha":"8a48b29d5e8f110041cca683dbef8ca6abf98b4d","user":{"login":"adaptlearning","id":5629464,"avatar_url":"https://avatars.githubusercontent.com/u/5629464?v=3","gravatar_id":"","url":"https://api.github.com/users/adaptlearning","html_url":"https://github.com/adaptlearning","followers_url":"https://api.github.com/users/adaptlearning/followers","following_url":"https://api.github.com/users/adaptlearning/following{/other_user}","gists_url":"https://api.github.com/users/adaptlearning/gists{/gist_id}","starred_url":"https://api.github.com/users/adaptlearning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adaptlearning/subscriptions","organizations_url":"https://api.github.com/users/adaptlearning/orgs","repos_url":"https://api.github.com/users/adaptlearning/repos","events_url":"https://api.github.com/users/adaptlearning/events{/privacy}","received_events_url":"https://api.github.com/users/adaptlearning/received_events","type":"Organization","site_admin":false},"repo":{"id":13562581,"name":"adapt_authoring","full_name":"adaptlearning/adapt_authoring","owner":{"login":"adaptlearning","id":5629464,"avatar_url":"https://avatars.githubusercontent.com/u/5629464?v=3","gravatar_id":"","url":"https://api.github.com/users/adaptlearning","html_url":"https://github.com/adaptlearning","followers_url":"https://api.github.com/users/adaptlearning/followers","following_url":"https://api.github.com/users/adaptlearning/following{/other_user}","gists_url":"https://api.github.com/users/adaptlearning/gists{/gist_id}","starred_url":"https://api.github.com/users/adaptlearning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adaptlearning/subscriptions","organizations_url":"https://api.github.com/users/adaptlearning/orgs","repos_url":"https://api.github.com/users/adaptlearning/repos","events_url":"https://api.github.com/users/adaptlearning/events{/privacy}","received_events_url":"https://api.github.com/users/adaptlearning/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/adaptlearning/adapt_authoring","description":"Source code for the Adapt Authoring tool","fork":false,"url":"https://api.github.com/repos/adaptlearning/adapt_authoring","forks_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/forks","keys_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/teams","hooks_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/hooks","issue_events_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/issues/events{/number}","events_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/events","assignees_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/assignees{/user}","branches_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/branches{/branch}","tags_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/tags","blobs_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/git/refs{/sha}","trees_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/statuses/{sha}","languages_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/languages","stargazers_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/stargazers","contributors_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/contributors","subscribers_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/subscribers","subscription_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/subscription","commits_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/commits{/sha}","git_commits_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/git/commits{/sha}","comments_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/comments{/number}","issue_comment_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/issues/comments{/number}","contents_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/contents/{+path}","compare_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/merges","archive_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/downloads","issues_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/issues{/number}","pulls_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/pulls{/number}","milestones_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/milestones{/number}","notifications_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/labels{/name}","releases_url":"https://api.github.com/repos/adaptlearning/adapt_authoring/releases{/id}","created_at":"2013-10-14T13:52:24Z","updated_at":"2015-03-31T09:33:54Z","pushed_at":"2015-03-31T09:33:52Z","git_url":"git://github.com/adaptlearning/adapt_authoring.git","ssh_url":"git@github.com:adaptlearning/adapt_authoring.git","clone_url":"https://github.com/adaptlearning/adapt_authoring.git","svn_url":"https://github.com/adaptlearning/adapt_authoring","homepage":null,"size":42711,"stargazers_count":26,"watchers_count":26,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":317,"forks":24,"open_issues":317,"watchers":26,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/adaptlearning/adapt_authoring/pulls/621"},"html":{"href":"https://github.com/adaptlearning/adapt_authoring/pull/621"},"issue":{"href":"https://api.github.com/repos/adaptlearning/adapt_authoring/issues/621"},"comments":{"href":"https://api.github.com/repos/adaptlearning/adapt_authoring/issues/621/comments"},"review_comments":{"href":"https://api.github.com/repos/adaptlearning/adapt_authoring/pulls/621/comments"},"review_comment":{"href":"https://api.github.com/repos/adaptlearning/adapt_authoring/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/adaptlearning/adapt_authoring/pulls/621/commits"},"statuses":{"href":"https://api.github.com/repos/adaptlearning/adapt_authoring/statuses/7999df56d8d2fdd4b33443298292eab39de246e7"}}}}