{"action":"created","comment":{"url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/pulls/comments/59972518","id":59972518,"diff_hunk":"@@ -2,8 +2,15 @@ module.exports = function(app){\n \tvar mongoDs = app.datasources.mongoDs;\n  \tvar ObjectID = mongoDs.connector.getDefaultIdType();\n  \tvar RoleMapping = app.models.RoleMapping;\n+ \tvar orgUser = app.models.orgUser;\n+ \tvar Role = app.models.Role;\n \n  \tRoleMapping.defineProperty('principalId', {\n  \t\ttype: ObjectID,\n  \t});\n+ \t\n+ \tRoleMapping.belongsTo(orgUser);","path":"server/boot/01_mongo_id_handler.js","position":11,"original_position":11,"commit_id":"76ad412f956ddd6b65dc66f4f26df9511a25846f","original_commit_id":"76ad412f956ddd6b65dc66f4f26df9511a25846f","user":{"login":"aquid","id":3837264,"avatar_url":"https://avatars.githubusercontent.com/u/3837264?v=3","gravatar_id":"","url":"https://api.github.com/users/aquid","html_url":"https://github.com/aquid","followers_url":"https://api.github.com/users/aquid/followers","following_url":"https://api.github.com/users/aquid/following{/other_user}","gists_url":"https://api.github.com/users/aquid/gists{/gist_id}","starred_url":"https://api.github.com/users/aquid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aquid/subscriptions","organizations_url":"https://api.github.com/users/aquid/orgs","repos_url":"https://api.github.com/users/aquid/repos","events_url":"https://api.github.com/users/aquid/events{/privacy}","received_events_url":"https://api.github.com/users/aquid/received_events","type":"User","site_admin":false},"body":"I think we don't need to add all those lines programatically but we might need this one \r\n```\r\norgUser.hasMany(Role, {through: RoleMapping, foreignKey: 'principalId'});\r\n```\r\nto fetch all the roles for a user. As when I tried to include the roles in currentUser middleware, I was getting an error.  And also I was in a different thought process of how to do the role resolver thing I forgot to do more experimentations with this :(","created_at":"2016-04-16T19:13:43Z","updated_at":"2016-04-16T19:13:43Z","html_url":"https://github.com/aquid/multi-tenancy-loopback/pull/3#discussion_r59972518","pull_request_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/aquid/multi-tenancy-loopback/pulls/comments/59972518"},"html":{"href":"https://github.com/aquid/multi-tenancy-loopback/pull/3#discussion_r59972518"},"pull_request":{"href":"https://api.github.com/repos/aquid/multi-tenancy-loopback/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/pulls/3","id":66743291,"html_url":"https://github.com/aquid/multi-tenancy-loopback/pull/3","diff_url":"https://github.com/aquid/multi-tenancy-loopback/pull/3.diff","patch_url":"https://github.com/aquid/multi-tenancy-loopback/pull/3.patch","issue_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/issues/3","number":3,"state":"open","locked":false,"title":"Feature/aquid role resolver","user":{"login":"aquid","id":3837264,"avatar_url":"https://avatars.githubusercontent.com/u/3837264?v=3","gravatar_id":"","url":"https://api.github.com/users/aquid","html_url":"https://github.com/aquid","followers_url":"https://api.github.com/users/aquid/followers","following_url":"https://api.github.com/users/aquid/following{/other_user}","gists_url":"https://api.github.com/users/aquid/gists{/gist_id}","starred_url":"https://api.github.com/users/aquid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aquid/subscriptions","organizations_url":"https://api.github.com/users/aquid/orgs","repos_url":"https://api.github.com/users/aquid/repos","events_url":"https://api.github.com/users/aquid/events{/privacy}","received_events_url":"https://api.github.com/users/aquid/received_events","type":"User","site_admin":false},"body":"@pulkitsinghal I have tried adding role resolver. Take a look at it.\r\n\r\nI have also added a `access observer hook` in the resolver to restrict the storeAdmin's to do any kind of includes for items models.\r\n\r\nhere's the sample\r\n\r\n```\r\nif(typeof itemModel.observe === 'function'){\r\n\titemModel.observe('access', (ctx, next) => {\r\n\t\tif(ctx.query.include && !isAdmin){\r\n\t\t\tdelete ctx.query.include;\r\n\t\t\treturn next();\r\n\t\t}\r\n\t        else{\r\n\t\t\treturn next();\r\n\t\t\t}\r\n\t});\r\n}\r\n```\r\n\r\nThis is done with reference to [this](https://github.com/fullcube/loopback-component-access-groups/blob/master/lib/utils.js#L54)","created_at":"2016-04-16T16:56:29Z","updated_at":"2016-04-16T19:13:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0e37a1011f7fd2b2584e2e06c595dc46779c9d95","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/pulls/3/commits","review_comments_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/pulls/3/comments","review_comment_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/issues/3/comments","statuses_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/statuses/76ad412f956ddd6b65dc66f4f26df9511a25846f","head":{"label":"aquid:feature/aquid_role_resolver","ref":"feature/aquid_role_resolver","sha":"76ad412f956ddd6b65dc66f4f26df9511a25846f","user":{"login":"aquid","id":3837264,"avatar_url":"https://avatars.githubusercontent.com/u/3837264?v=3","gravatar_id":"","url":"https://api.github.com/users/aquid","html_url":"https://github.com/aquid","followers_url":"https://api.github.com/users/aquid/followers","following_url":"https://api.github.com/users/aquid/following{/other_user}","gists_url":"https://api.github.com/users/aquid/gists{/gist_id}","starred_url":"https://api.github.com/users/aquid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aquid/subscriptions","organizations_url":"https://api.github.com/users/aquid/orgs","repos_url":"https://api.github.com/users/aquid/repos","events_url":"https://api.github.com/users/aquid/events{/privacy}","received_events_url":"https://api.github.com/users/aquid/received_events","type":"User","site_admin":false},"repo":{"id":55357744,"name":"multi-tenancy-loopback","full_name":"aquid/multi-tenancy-loopback","owner":{"login":"aquid","id":3837264,"avatar_url":"https://avatars.githubusercontent.com/u/3837264?v=3","gravatar_id":"","url":"https://api.github.com/users/aquid","html_url":"https://github.com/aquid","followers_url":"https://api.github.com/users/aquid/followers","following_url":"https://api.github.com/users/aquid/following{/other_user}","gists_url":"https://api.github.com/users/aquid/gists{/gist_id}","starred_url":"https://api.github.com/users/aquid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aquid/subscriptions","organizations_url":"https://api.github.com/users/aquid/orgs","repos_url":"https://api.github.com/users/aquid/repos","events_url":"https://api.github.com/users/aquid/events{/privacy}","received_events_url":"https://api.github.com/users/aquid/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aquid/multi-tenancy-loopback","description":"Check multi tenancy with loopback using mongodb","fork":false,"url":"https://api.github.com/repos/aquid/multi-tenancy-loopback","forks_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/forks","keys_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/teams","hooks_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/hooks","issue_events_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/issues/events{/number}","events_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/events","assignees_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/assignees{/user}","branches_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/branches{/branch}","tags_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/tags","blobs_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/git/refs{/sha}","trees_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/statuses/{sha}","languages_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/languages","stargazers_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/stargazers","contributors_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/contributors","subscribers_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/subscribers","subscription_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/subscription","commits_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/commits{/sha}","git_commits_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/git/commits{/sha}","comments_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/comments{/number}","issue_comment_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/issues/comments{/number}","contents_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/contents/{+path}","compare_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/merges","archive_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/downloads","issues_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/issues{/number}","pulls_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/pulls{/number}","milestones_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/milestones{/number}","notifications_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/labels{/name}","releases_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/releases{/id}","deployments_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/deployments","created_at":"2016-04-03T16:58:23Z","updated_at":"2016-04-03T17:26:36Z","pushed_at":"2016-04-16T16:56:29Z","git_url":"git://github.com/aquid/multi-tenancy-loopback.git","ssh_url":"git@github.com:aquid/multi-tenancy-loopback.git","clone_url":"https://github.com/aquid/multi-tenancy-loopback.git","svn_url":"https://github.com/aquid/multi-tenancy-loopback","homepage":"","size":30,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"aquid:master","ref":"master","sha":"88bfbb129da1fa754ede7fef3dc11ca66abaf27c","user":{"login":"aquid","id":3837264,"avatar_url":"https://avatars.githubusercontent.com/u/3837264?v=3","gravatar_id":"","url":"https://api.github.com/users/aquid","html_url":"https://github.com/aquid","followers_url":"https://api.github.com/users/aquid/followers","following_url":"https://api.github.com/users/aquid/following{/other_user}","gists_url":"https://api.github.com/users/aquid/gists{/gist_id}","starred_url":"https://api.github.com/users/aquid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aquid/subscriptions","organizations_url":"https://api.github.com/users/aquid/orgs","repos_url":"https://api.github.com/users/aquid/repos","events_url":"https://api.github.com/users/aquid/events{/privacy}","received_events_url":"https://api.github.com/users/aquid/received_events","type":"User","site_admin":false},"repo":{"id":55357744,"name":"multi-tenancy-loopback","full_name":"aquid/multi-tenancy-loopback","owner":{"login":"aquid","id":3837264,"avatar_url":"https://avatars.githubusercontent.com/u/3837264?v=3","gravatar_id":"","url":"https://api.github.com/users/aquid","html_url":"https://github.com/aquid","followers_url":"https://api.github.com/users/aquid/followers","following_url":"https://api.github.com/users/aquid/following{/other_user}","gists_url":"https://api.github.com/users/aquid/gists{/gist_id}","starred_url":"https://api.github.com/users/aquid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aquid/subscriptions","organizations_url":"https://api.github.com/users/aquid/orgs","repos_url":"https://api.github.com/users/aquid/repos","events_url":"https://api.github.com/users/aquid/events{/privacy}","received_events_url":"https://api.github.com/users/aquid/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aquid/multi-tenancy-loopback","description":"Check multi tenancy with loopback using mongodb","fork":false,"url":"https://api.github.com/repos/aquid/multi-tenancy-loopback","forks_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/forks","keys_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/teams","hooks_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/hooks","issue_events_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/issues/events{/number}","events_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/events","assignees_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/assignees{/user}","branches_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/branches{/branch}","tags_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/tags","blobs_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/git/refs{/sha}","trees_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/statuses/{sha}","languages_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/languages","stargazers_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/stargazers","contributors_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/contributors","subscribers_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/subscribers","subscription_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/subscription","commits_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/commits{/sha}","git_commits_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/git/commits{/sha}","comments_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/comments{/number}","issue_comment_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/issues/comments{/number}","contents_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/contents/{+path}","compare_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/merges","archive_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/downloads","issues_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/issues{/number}","pulls_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/pulls{/number}","milestones_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/milestones{/number}","notifications_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/labels{/name}","releases_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/releases{/id}","deployments_url":"https://api.github.com/repos/aquid/multi-tenancy-loopback/deployments","created_at":"2016-04-03T16:58:23Z","updated_at":"2016-04-03T17:26:36Z","pushed_at":"2016-04-16T16:56:29Z","git_url":"git://github.com/aquid/multi-tenancy-loopback.git","ssh_url":"git@github.com:aquid/multi-tenancy-loopback.git","clone_url":"https://github.com/aquid/multi-tenancy-loopback.git","svn_url":"https://github.com/aquid/multi-tenancy-loopback","homepage":"","size":30,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aquid/multi-tenancy-loopback/pulls/3"},"html":{"href":"https://github.com/aquid/multi-tenancy-loopback/pull/3"},"issue":{"href":"https://api.github.com/repos/aquid/multi-tenancy-loopback/issues/3"},"comments":{"href":"https://api.github.com/repos/aquid/multi-tenancy-loopback/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/aquid/multi-tenancy-loopback/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/aquid/multi-tenancy-loopback/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aquid/multi-tenancy-loopback/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/aquid/multi-tenancy-loopback/statuses/76ad412f956ddd6b65dc66f4f26df9511a25846f"}}}}