{"action":"created","comment":{"url":"https://api.github.com/repos/strongloop/loopback/pulls/comments/104160219","pull_request_review_id":24980875,"id":104160219,"diff_hunk":"@@ -96,7 +96,7 @@ function token(options) {\n     var registry = app.registry;\n     if (!TokenModel) {\n       if (registry === loopback.registry) {\n-        TokenModel = options.model || loopback.AccessToken;\n+        TokenModel = app.models[options.model] || loopback.AccessToken;","path":"server/middleware/token.js","position":5,"original_position":5,"commit_id":"d804e927344cbb153b9a04d242a7401a51f5b65e","original_commit_id":"d804e927344cbb153b9a04d242a7401a51f5b65e","user":{"login":"bajtos","id":1140553,"avatar_url":"https://avatars2.githubusercontent.com/u/1140553?v=3","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false},"body":"Agreed +1","created_at":"2017-03-03T14:16:55Z","updated_at":"2017-03-03T14:16:56Z","html_url":"https://github.com/strongloop/loopback/pull/3245#discussion_r104160219","pull_request_url":"https://api.github.com/repos/strongloop/loopback/pulls/3245","_links":{"self":{"href":"https://api.github.com/repos/strongloop/loopback/pulls/comments/104160219"},"html":{"href":"https://github.com/strongloop/loopback/pull/3245#discussion_r104160219"},"pull_request":{"href":"https://api.github.com/repos/strongloop/loopback/pulls/3245"}}},"pull_request":{"url":"https://api.github.com/repos/strongloop/loopback/pulls/3245","id":108957359,"html_url":"https://github.com/strongloop/loopback/pull/3245","diff_url":"https://github.com/strongloop/loopback/pull/3245.diff","patch_url":"https://github.com/strongloop/loopback/pull/3245.patch","issue_url":"https://api.github.com/repos/strongloop/loopback/issues/3245","number":3245,"state":"open","locked":false,"title":"fix custom token model in token middleware","user":{"login":"ebarault","id":12000935,"avatar_url":"https://avatars0.githubusercontent.com/u/12000935?v=3","gravatar_id":"","url":"https://api.github.com/users/ebarault","html_url":"https://github.com/ebarault","followers_url":"https://api.github.com/users/ebarault/followers","following_url":"https://api.github.com/users/ebarault/following{/other_user}","gists_url":"https://api.github.com/users/ebarault/gists{/gist_id}","starred_url":"https://api.github.com/users/ebarault/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebarault/subscriptions","organizations_url":"https://api.github.com/users/ebarault/orgs","repos_url":"https://api.github.com/users/ebarault/repos","events_url":"https://api.github.com/users/ebarault/events{/privacy}","received_events_url":"https://api.github.com/users/ebarault/received_events","type":"User","site_admin":false},"body":"cc @bajtos @beeman \r\n\r\n### Description\r\nSpecifying a custom AccessToken model via the auth middleware options is broken when the app is using a single global registry.\r\n\r\nThe faulty line are \r\n```\r\nif (registry === loopback.registry) {\r\n  TokenModel = options.model || loopback.AccessToken;\r\n} \r\n```\r\nwhere `options.model` is the model name in the token middleware config, not the model itself\r\nmore comments inlined in the code itself\r\n\r\n**Note**: New tests should be added to cover properly the scenario where a custom AccessToken is specified using the token middleware.\r\n\r\n#### Related issues\r\nhttps://github.com/strongloop/loopback.io/pull/297#issuecomment-283866261\r\n\r\n<!--\r\nPlease use the following link syntaxes:\r\n\r\n- #49 (to reference issues in the current repository)\r\n- strongloop/loopback#49 (to reference issues in another repository)\r\n-->\r\n\r\n- None\r\n\r\n### Checklist\r\n\r\n<!--\r\nPlease mark your choice with an \"x\" (i.e. [x], see\r\nhttps://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments)\r\n-->\r\n\r\n- [ ] New tests added or existing tests modified to cover all changes\r\n- [ ] Code conforms with the [style\r\n  guide](http://loopback.io/doc/en/contrib/style-guide.html)\r\n","created_at":"2017-03-03T11:43:01Z","updated_at":"2017-03-03T14:16:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6555b4fc845ae8c0a236bf9be8513ae4bf24f9d6","assignee":{"login":"ebarault","id":12000935,"avatar_url":"https://avatars0.githubusercontent.com/u/12000935?v=3","gravatar_id":"","url":"https://api.github.com/users/ebarault","html_url":"https://github.com/ebarault","followers_url":"https://api.github.com/users/ebarault/followers","following_url":"https://api.github.com/users/ebarault/following{/other_user}","gists_url":"https://api.github.com/users/ebarault/gists{/gist_id}","starred_url":"https://api.github.com/users/ebarault/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebarault/subscriptions","organizations_url":"https://api.github.com/users/ebarault/orgs","repos_url":"https://api.github.com/users/ebarault/repos","events_url":"https://api.github.com/users/ebarault/events{/privacy}","received_events_url":"https://api.github.com/users/ebarault/received_events","type":"User","site_admin":false},"assignees":[{"login":"ebarault","id":12000935,"avatar_url":"https://avatars0.githubusercontent.com/u/12000935?v=3","gravatar_id":"","url":"https://api.github.com/users/ebarault","html_url":"https://github.com/ebarault","followers_url":"https://api.github.com/users/ebarault/followers","following_url":"https://api.github.com/users/ebarault/following{/other_user}","gists_url":"https://api.github.com/users/ebarault/gists{/gist_id}","starred_url":"https://api.github.com/users/ebarault/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebarault/subscriptions","organizations_url":"https://api.github.com/users/ebarault/orgs","repos_url":"https://api.github.com/users/ebarault/repos","events_url":"https://api.github.com/users/ebarault/events{/privacy}","received_events_url":"https://api.github.com/users/ebarault/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/strongloop/loopback/pulls/3245/commits","review_comments_url":"https://api.github.com/repos/strongloop/loopback/pulls/3245/comments","review_comment_url":"https://api.github.com/repos/strongloop/loopback/pulls/comments{/number}","comments_url":"https://api.github.com/repos/strongloop/loopback/issues/3245/comments","statuses_url":"https://api.github.com/repos/strongloop/loopback/statuses/d804e927344cbb153b9a04d242a7401a51f5b65e","head":{"label":"strongloop:fix/token-middleware-custom-model","ref":"fix/token-middleware-custom-model","sha":"d804e927344cbb153b9a04d242a7401a51f5b65e","user":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars2.githubusercontent.com/u/3020012?v=3","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"repo":{"id":9325315,"name":"loopback","full_name":"strongloop/loopback","owner":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars2.githubusercontent.com/u/3020012?v=3","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/strongloop/loopback","description":"LoopBack is an open source Node.js framework built on top of Express optimized for building APIs for mobile, web, and other devices. Connect to multiple data sources, write business logic in Node.js, glue on top of your existing services and data, connect using JS, iOS & Android SDKs.","fork":false,"url":"https://api.github.com/repos/strongloop/loopback","forks_url":"https://api.github.com/repos/strongloop/loopback/forks","keys_url":"https://api.github.com/repos/strongloop/loopback/keys{/key_id}","collaborators_url":"https://api.github.com/repos/strongloop/loopback/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/strongloop/loopback/teams","hooks_url":"https://api.github.com/repos/strongloop/loopback/hooks","issue_events_url":"https://api.github.com/repos/strongloop/loopback/issues/events{/number}","events_url":"https://api.github.com/repos/strongloop/loopback/events","assignees_url":"https://api.github.com/repos/strongloop/loopback/assignees{/user}","branches_url":"https://api.github.com/repos/strongloop/loopback/branches{/branch}","tags_url":"https://api.github.com/repos/strongloop/loopback/tags","blobs_url":"https://api.github.com/repos/strongloop/loopback/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/strongloop/loopback/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/strongloop/loopback/git/refs{/sha}","trees_url":"https://api.github.com/repos/strongloop/loopback/git/trees{/sha}","statuses_url":"https://api.github.com/repos/strongloop/loopback/statuses/{sha}","languages_url":"https://api.github.com/repos/strongloop/loopback/languages","stargazers_url":"https://api.github.com/repos/strongloop/loopback/stargazers","contributors_url":"https://api.github.com/repos/strongloop/loopback/contributors","subscribers_url":"https://api.github.com/repos/strongloop/loopback/subscribers","subscription_url":"https://api.github.com/repos/strongloop/loopback/subscription","commits_url":"https://api.github.com/repos/strongloop/loopback/commits{/sha}","git_commits_url":"https://api.github.com/repos/strongloop/loopback/git/commits{/sha}","comments_url":"https://api.github.com/repos/strongloop/loopback/comments{/number}","issue_comment_url":"https://api.github.com/repos/strongloop/loopback/issues/comments{/number}","contents_url":"https://api.github.com/repos/strongloop/loopback/contents/{+path}","compare_url":"https://api.github.com/repos/strongloop/loopback/compare/{base}...{head}","merges_url":"https://api.github.com/repos/strongloop/loopback/merges","archive_url":"https://api.github.com/repos/strongloop/loopback/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/strongloop/loopback/downloads","issues_url":"https://api.github.com/repos/strongloop/loopback/issues{/number}","pulls_url":"https://api.github.com/repos/strongloop/loopback/pulls{/number}","milestones_url":"https://api.github.com/repos/strongloop/loopback/milestones{/number}","notifications_url":"https://api.github.com/repos/strongloop/loopback/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/strongloop/loopback/labels{/name}","releases_url":"https://api.github.com/repos/strongloop/loopback/releases{/id}","deployments_url":"https://api.github.com/repos/strongloop/loopback/deployments","created_at":"2013-04-09T16:02:18Z","updated_at":"2017-03-03T13:01:34Z","pushed_at":"2017-03-03T11:43:02Z","git_url":"git://github.com/strongloop/loopback.git","ssh_url":"git@github.com:strongloop/loopback.git","clone_url":"https://github.com/strongloop/loopback.git","svn_url":"https://github.com/strongloop/loopback","homepage":"http://loopback.io","size":7861,"stargazers_count":8389,"watchers_count":8389,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":814,"mirror_url":null,"open_issues_count":541,"forks":814,"open_issues":541,"watchers":8389,"default_branch":"master"}},"base":{"label":"strongloop:master","ref":"master","sha":"ed4f56c7f8f8405e0b61246af3a5f9d2382b78da","user":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars2.githubusercontent.com/u/3020012?v=3","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"repo":{"id":9325315,"name":"loopback","full_name":"strongloop/loopback","owner":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars2.githubusercontent.com/u/3020012?v=3","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/strongloop/loopback","description":"LoopBack is an open source Node.js framework built on top of Express optimized for building APIs for mobile, web, and other devices. Connect to multiple data sources, write business logic in Node.js, glue on top of your existing services and data, connect using JS, iOS & Android SDKs.","fork":false,"url":"https://api.github.com/repos/strongloop/loopback","forks_url":"https://api.github.com/repos/strongloop/loopback/forks","keys_url":"https://api.github.com/repos/strongloop/loopback/keys{/key_id}","collaborators_url":"https://api.github.com/repos/strongloop/loopback/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/strongloop/loopback/teams","hooks_url":"https://api.github.com/repos/strongloop/loopback/hooks","issue_events_url":"https://api.github.com/repos/strongloop/loopback/issues/events{/number}","events_url":"https://api.github.com/repos/strongloop/loopback/events","assignees_url":"https://api.github.com/repos/strongloop/loopback/assignees{/user}","branches_url":"https://api.github.com/repos/strongloop/loopback/branches{/branch}","tags_url":"https://api.github.com/repos/strongloop/loopback/tags","blobs_url":"https://api.github.com/repos/strongloop/loopback/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/strongloop/loopback/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/strongloop/loopback/git/refs{/sha}","trees_url":"https://api.github.com/repos/strongloop/loopback/git/trees{/sha}","statuses_url":"https://api.github.com/repos/strongloop/loopback/statuses/{sha}","languages_url":"https://api.github.com/repos/strongloop/loopback/languages","stargazers_url":"https://api.github.com/repos/strongloop/loopback/stargazers","contributors_url":"https://api.github.com/repos/strongloop/loopback/contributors","subscribers_url":"https://api.github.com/repos/strongloop/loopback/subscribers","subscription_url":"https://api.github.com/repos/strongloop/loopback/subscription","commits_url":"https://api.github.com/repos/strongloop/loopback/commits{/sha}","git_commits_url":"https://api.github.com/repos/strongloop/loopback/git/commits{/sha}","comments_url":"https://api.github.com/repos/strongloop/loopback/comments{/number}","issue_comment_url":"https://api.github.com/repos/strongloop/loopback/issues/comments{/number}","contents_url":"https://api.github.com/repos/strongloop/loopback/contents/{+path}","compare_url":"https://api.github.com/repos/strongloop/loopback/compare/{base}...{head}","merges_url":"https://api.github.com/repos/strongloop/loopback/merges","archive_url":"https://api.github.com/repos/strongloop/loopback/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/strongloop/loopback/downloads","issues_url":"https://api.github.com/repos/strongloop/loopback/issues{/number}","pulls_url":"https://api.github.com/repos/strongloop/loopback/pulls{/number}","milestones_url":"https://api.github.com/repos/strongloop/loopback/milestones{/number}","notifications_url":"https://api.github.com/repos/strongloop/loopback/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/strongloop/loopback/labels{/name}","releases_url":"https://api.github.com/repos/strongloop/loopback/releases{/id}","deployments_url":"https://api.github.com/repos/strongloop/loopback/deployments","created_at":"2013-04-09T16:02:18Z","updated_at":"2017-03-03T13:01:34Z","pushed_at":"2017-03-03T11:43:02Z","git_url":"git://github.com/strongloop/loopback.git","ssh_url":"git@github.com:strongloop/loopback.git","clone_url":"https://github.com/strongloop/loopback.git","svn_url":"https://github.com/strongloop/loopback","homepage":"http://loopback.io","size":7861,"stargazers_count":8389,"watchers_count":8389,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":814,"mirror_url":null,"open_issues_count":541,"forks":814,"open_issues":541,"watchers":8389,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/strongloop/loopback/pulls/3245"},"html":{"href":"https://github.com/strongloop/loopback/pull/3245"},"issue":{"href":"https://api.github.com/repos/strongloop/loopback/issues/3245"},"comments":{"href":"https://api.github.com/repos/strongloop/loopback/issues/3245/comments"},"review_comments":{"href":"https://api.github.com/repos/strongloop/loopback/pulls/3245/comments"},"review_comment":{"href":"https://api.github.com/repos/strongloop/loopback/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/strongloop/loopback/pulls/3245/commits"},"statuses":{"href":"https://api.github.com/repos/strongloop/loopback/statuses/d804e927344cbb153b9a04d242a7401a51f5b65e"}}}}
{"actor":{"display_login":"bajtos"}}