{"action":"created","comment":{"url":"https://api.github.com/repos/Vestorly/torii/pulls/comments/38279085","id":38279085,"diff_hunk":"@@ -0,0 +1,18 @@\n+var Router = Ember.Router;\n+var proto = Ember.RouterDSL.prototype;\n+\n+var currentMap = null;\n+\n+proto.authenticatedRoute = function() {\n+  this.route.apply(this, arguments);\n+  currentMap.push(arguments[0]);\n+};\n+\n+// 1.10 and above","path":"lib/torii/router-dsl-ext.js","position":11,"original_position":11,"commit_id":"421a8188462b52a0349f6eff8741892a2cae2842","original_commit_id":"421a8188462b52a0349f6eff8741892a2cae2842","user":{"login":"mixonic","id":8752,"avatar_url":"https://avatars.githubusercontent.com/u/8752?v=3","gravatar_id":"","url":"https://api.github.com/users/mixonic","html_url":"https://github.com/mixonic","followers_url":"https://api.github.com/users/mixonic/followers","following_url":"https://api.github.com/users/mixonic/following{/other_user}","gists_url":"https://api.github.com/users/mixonic/gists{/gist_id}","starred_url":"https://api.github.com/users/mixonic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mixonic/subscriptions","organizations_url":"https://api.github.com/users/mixonic/orgs","repos_url":"https://api.github.com/users/mixonic/repos","events_url":"https://api.github.com/users/mixonic/events{/privacy}","received_events_url":"https://api.github.com/users/mixonic/received_events","type":"User","site_admin":false},"body":"0.4.x is already >= 1.12 :+1: ","created_at":"2015-08-31T00:56:55Z","updated_at":"2015-08-31T00:56:55Z","html_url":"https://github.com/Vestorly/torii/pull/200#discussion_r38279085","pull_request_url":"https://api.github.com/repos/Vestorly/torii/pulls/200","_links":{"self":{"href":"https://api.github.com/repos/Vestorly/torii/pulls/comments/38279085"},"html":{"href":"https://github.com/Vestorly/torii/pull/200#discussion_r38279085"},"pull_request":{"href":"https://api.github.com/repos/Vestorly/torii/pulls/200"}}},"pull_request":{"url":"https://api.github.com/repos/Vestorly/torii/pulls/200","id":39870332,"html_url":"https://github.com/Vestorly/torii/pull/200","diff_url":"https://github.com/Vestorly/torii/pull/200.diff","patch_url":"https://github.com/Vestorly/torii/pull/200.patch","issue_url":"https://api.github.com/repos/Vestorly/torii/issues/200","number":200,"state":"open","locked":false,"title":"authenticatedRoute Router DSL","user":{"login":"taras","id":74687,"avatar_url":"https://avatars.githubusercontent.com/u/74687?v=3","gravatar_id":"","url":"https://api.github.com/users/taras","html_url":"https://github.com/taras","followers_url":"https://api.github.com/users/taras/followers","following_url":"https://api.github.com/users/taras/following{/other_user}","gists_url":"https://api.github.com/users/taras/gists{/gist_id}","starred_url":"https://api.github.com/users/taras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taras/subscriptions","organizations_url":"https://api.github.com/users/taras/orgs","repos_url":"https://api.github.com/users/taras/repos","events_url":"https://api.github.com/users/taras/events{/privacy}","received_events_url":"https://api.github.com/users/taras/received_events","type":"User","site_admin":false},"body":"This PR is a follow up to a conversation that @mixonic and I had via Slack about eliminating the need for adding a route mixin to make routes ensure they have authentication. Please, consider this a rough draft. \r\n\r\nThis PR provides function called `authenticatedRoute` that can be used in Router map to mark specific routes as requiring authentication. Here is an example:\r\n\r\n```js\r\nimport Ember from 'ember';\r\nimport config from './config/environment';\r\nvar Router = Ember.Router.extend({\r\n  location: config.locationType\r\n});\r\n\r\nexport default Router.map(function() {\r\n  this.authenticatedRoute('add');\r\n});\r\n```\r\n\r\nWhen at least one `authenticatedRoute` route is present, the app will automatically attempt to `checkLogin` which will call `session.fetch`. To reduce boilerplate, I added a `sessionProvider` property to Torii config which allows to set which session provider should be fetched: ie. `this.session.fetch(config.sessionProvider)`\r\n\r\nWhat do you think about this?\r\n\r\nQuestions:\r\n~~1. Currently, the user has to overwrite `accessDenied` on each route. Should we take that from ApplicationRoute? or maybe send a `accessDenied` action?~~\r\n~~2. What do you think about `sessionProvider`?~~\r\n\r\n## TODO\r\n\r\n- [x] `authenticatedRoute` function \r\n- [x] Test mixin is not added if sessionName is not specified\r\n- [x] Test mixin is added when sessionName is specified\r\n- [x] Test `checkLogin` is not called when there are no `authentictedRoutes`\r\n- [x] Test `checkLogin` is called with `authenticatedRoutes` present\r\n- [x] Test `accessDenied` hook is called when access is denied\r\n- [x] Test session is retrieved\r\n- [x] Test session.fetchDefaultProvider\r\n- [x] Add authenticatedRoute Router DSL Extension\r\n- [x] Add test for Router DSL Extension\r\n- [x] Ensure accessDenied action is sent to transition\r\n- [ ] Add documentation to README","created_at":"2015-07-14T00:11:20Z","updated_at":"2015-08-31T00:56:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8f1f48998dd8a341e2c0e2ba677683f1fe0a74fd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Vestorly/torii/pulls/200/commits","review_comments_url":"https://api.github.com/repos/Vestorly/torii/pulls/200/comments","review_comment_url":"https://api.github.com/repos/Vestorly/torii/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Vestorly/torii/issues/200/comments","statuses_url":"https://api.github.com/repos/Vestorly/torii/statuses/421a8188462b52a0349f6eff8741892a2cae2842","head":{"label":"embersherpa:master","ref":"master","sha":"421a8188462b52a0349f6eff8741892a2cae2842","user":{"login":"embersherpa","id":6191081,"avatar_url":"https://avatars.githubusercontent.com/u/6191081?v=3","gravatar_id":"","url":"https://api.github.com/users/embersherpa","html_url":"https://github.com/embersherpa","followers_url":"https://api.github.com/users/embersherpa/followers","following_url":"https://api.github.com/users/embersherpa/following{/other_user}","gists_url":"https://api.github.com/users/embersherpa/gists{/gist_id}","starred_url":"https://api.github.com/users/embersherpa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/embersherpa/subscriptions","organizations_url":"https://api.github.com/users/embersherpa/orgs","repos_url":"https://api.github.com/users/embersherpa/repos","events_url":"https://api.github.com/users/embersherpa/events{/privacy}","received_events_url":"https://api.github.com/users/embersherpa/received_events","type":"Organization","site_admin":false},"repo":{"id":38819617,"name":"torii","full_name":"embersherpa/torii","owner":{"login":"embersherpa","id":6191081,"avatar_url":"https://avatars.githubusercontent.com/u/6191081?v=3","gravatar_id":"","url":"https://api.github.com/users/embersherpa","html_url":"https://github.com/embersherpa","followers_url":"https://api.github.com/users/embersherpa/followers","following_url":"https://api.github.com/users/embersherpa/following{/other_user}","gists_url":"https://api.github.com/users/embersherpa/gists{/gist_id}","starred_url":"https://api.github.com/users/embersherpa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/embersherpa/subscriptions","organizations_url":"https://api.github.com/users/embersherpa/orgs","repos_url":"https://api.github.com/users/embersherpa/repos","events_url":"https://api.github.com/users/embersherpa/events{/privacy}","received_events_url":"https://api.github.com/users/embersherpa/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/embersherpa/torii","description":"A set of clean abstractions for authentication in Ember.js","fork":true,"url":"https://api.github.com/repos/embersherpa/torii","forks_url":"https://api.github.com/repos/embersherpa/torii/forks","keys_url":"https://api.github.com/repos/embersherpa/torii/keys{/key_id}","collaborators_url":"https://api.github.com/repos/embersherpa/torii/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/embersherpa/torii/teams","hooks_url":"https://api.github.com/repos/embersherpa/torii/hooks","issue_events_url":"https://api.github.com/repos/embersherpa/torii/issues/events{/number}","events_url":"https://api.github.com/repos/embersherpa/torii/events","assignees_url":"https://api.github.com/repos/embersherpa/torii/assignees{/user}","branches_url":"https://api.github.com/repos/embersherpa/torii/branches{/branch}","tags_url":"https://api.github.com/repos/embersherpa/torii/tags","blobs_url":"https://api.github.com/repos/embersherpa/torii/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/embersherpa/torii/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/embersherpa/torii/git/refs{/sha}","trees_url":"https://api.github.com/repos/embersherpa/torii/git/trees{/sha}","statuses_url":"https://api.github.com/repos/embersherpa/torii/statuses/{sha}","languages_url":"https://api.github.com/repos/embersherpa/torii/languages","stargazers_url":"https://api.github.com/repos/embersherpa/torii/stargazers","contributors_url":"https://api.github.com/repos/embersherpa/torii/contributors","subscribers_url":"https://api.github.com/repos/embersherpa/torii/subscribers","subscription_url":"https://api.github.com/repos/embersherpa/torii/subscription","commits_url":"https://api.github.com/repos/embersherpa/torii/commits{/sha}","git_commits_url":"https://api.github.com/repos/embersherpa/torii/git/commits{/sha}","comments_url":"https://api.github.com/repos/embersherpa/torii/comments{/number}","issue_comment_url":"https://api.github.com/repos/embersherpa/torii/issues/comments{/number}","contents_url":"https://api.github.com/repos/embersherpa/torii/contents/{+path}","compare_url":"https://api.github.com/repos/embersherpa/torii/compare/{base}...{head}","merges_url":"https://api.github.com/repos/embersherpa/torii/merges","archive_url":"https://api.github.com/repos/embersherpa/torii/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/embersherpa/torii/downloads","issues_url":"https://api.github.com/repos/embersherpa/torii/issues{/number}","pulls_url":"https://api.github.com/repos/embersherpa/torii/pulls{/number}","milestones_url":"https://api.github.com/repos/embersherpa/torii/milestones{/number}","notifications_url":"https://api.github.com/repos/embersherpa/torii/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/embersherpa/torii/labels{/name}","releases_url":"https://api.github.com/repos/embersherpa/torii/releases{/id}","created_at":"2015-07-09T12:44:35Z","updated_at":"2015-07-09T12:44:35Z","pushed_at":"2015-07-28T17:25:38Z","git_url":"git://github.com/embersherpa/torii.git","ssh_url":"git@github.com:embersherpa/torii.git","clone_url":"https://github.com/embersherpa/torii.git","svn_url":"https://github.com/embersherpa/torii","homepage":"vestorly.github.io/torii","size":2446,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Vestorly:master","ref":"master","sha":"688d5db206fe7819fdccced470afcd93bd179a33","user":{"login":"Vestorly","id":1341524,"avatar_url":"https://avatars.githubusercontent.com/u/1341524?v=3","gravatar_id":"","url":"https://api.github.com/users/Vestorly","html_url":"https://github.com/Vestorly","followers_url":"https://api.github.com/users/Vestorly/followers","following_url":"https://api.github.com/users/Vestorly/following{/other_user}","gists_url":"https://api.github.com/users/Vestorly/gists{/gist_id}","starred_url":"https://api.github.com/users/Vestorly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vestorly/subscriptions","organizations_url":"https://api.github.com/users/Vestorly/orgs","repos_url":"https://api.github.com/users/Vestorly/repos","events_url":"https://api.github.com/users/Vestorly/events{/privacy}","received_events_url":"https://api.github.com/users/Vestorly/received_events","type":"Organization","site_admin":false},"repo":{"id":18303148,"name":"torii","full_name":"Vestorly/torii","owner":{"login":"Vestorly","id":1341524,"avatar_url":"https://avatars.githubusercontent.com/u/1341524?v=3","gravatar_id":"","url":"https://api.github.com/users/Vestorly","html_url":"https://github.com/Vestorly","followers_url":"https://api.github.com/users/Vestorly/followers","following_url":"https://api.github.com/users/Vestorly/following{/other_user}","gists_url":"https://api.github.com/users/Vestorly/gists{/gist_id}","starred_url":"https://api.github.com/users/Vestorly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vestorly/subscriptions","organizations_url":"https://api.github.com/users/Vestorly/orgs","repos_url":"https://api.github.com/users/Vestorly/repos","events_url":"https://api.github.com/users/Vestorly/events{/privacy}","received_events_url":"https://api.github.com/users/Vestorly/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Vestorly/torii","description":"A set of clean abstractions for authentication in Ember.js","fork":false,"url":"https://api.github.com/repos/Vestorly/torii","forks_url":"https://api.github.com/repos/Vestorly/torii/forks","keys_url":"https://api.github.com/repos/Vestorly/torii/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Vestorly/torii/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Vestorly/torii/teams","hooks_url":"https://api.github.com/repos/Vestorly/torii/hooks","issue_events_url":"https://api.github.com/repos/Vestorly/torii/issues/events{/number}","events_url":"https://api.github.com/repos/Vestorly/torii/events","assignees_url":"https://api.github.com/repos/Vestorly/torii/assignees{/user}","branches_url":"https://api.github.com/repos/Vestorly/torii/branches{/branch}","tags_url":"https://api.github.com/repos/Vestorly/torii/tags","blobs_url":"https://api.github.com/repos/Vestorly/torii/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Vestorly/torii/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Vestorly/torii/git/refs{/sha}","trees_url":"https://api.github.com/repos/Vestorly/torii/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Vestorly/torii/statuses/{sha}","languages_url":"https://api.github.com/repos/Vestorly/torii/languages","stargazers_url":"https://api.github.com/repos/Vestorly/torii/stargazers","contributors_url":"https://api.github.com/repos/Vestorly/torii/contributors","subscribers_url":"https://api.github.com/repos/Vestorly/torii/subscribers","subscription_url":"https://api.github.com/repos/Vestorly/torii/subscription","commits_url":"https://api.github.com/repos/Vestorly/torii/commits{/sha}","git_commits_url":"https://api.github.com/repos/Vestorly/torii/git/commits{/sha}","comments_url":"https://api.github.com/repos/Vestorly/torii/comments{/number}","issue_comment_url":"https://api.github.com/repos/Vestorly/torii/issues/comments{/number}","contents_url":"https://api.github.com/repos/Vestorly/torii/contents/{+path}","compare_url":"https://api.github.com/repos/Vestorly/torii/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Vestorly/torii/merges","archive_url":"https://api.github.com/repos/Vestorly/torii/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Vestorly/torii/downloads","issues_url":"https://api.github.com/repos/Vestorly/torii/issues{/number}","pulls_url":"https://api.github.com/repos/Vestorly/torii/pulls{/number}","milestones_url":"https://api.github.com/repos/Vestorly/torii/milestones{/number}","notifications_url":"https://api.github.com/repos/Vestorly/torii/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Vestorly/torii/labels{/name}","releases_url":"https://api.github.com/repos/Vestorly/torii/releases{/id}","created_at":"2014-03-31T18:16:42Z","updated_at":"2015-08-30T20:24:57Z","pushed_at":"2015-08-31T00:43:31Z","git_url":"git://github.com/Vestorly/torii.git","ssh_url":"git@github.com:Vestorly/torii.git","clone_url":"https://github.com/Vestorly/torii.git","svn_url":"https://github.com/Vestorly/torii","homepage":"vestorly.github.io/torii","size":3732,"stargazers_count":528,"watchers_count":528,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":81,"mirror_url":null,"open_issues_count":30,"forks":81,"open_issues":30,"watchers":528,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Vestorly/torii/pulls/200"},"html":{"href":"https://github.com/Vestorly/torii/pull/200"},"issue":{"href":"https://api.github.com/repos/Vestorly/torii/issues/200"},"comments":{"href":"https://api.github.com/repos/Vestorly/torii/issues/200/comments"},"review_comments":{"href":"https://api.github.com/repos/Vestorly/torii/pulls/200/comments"},"review_comment":{"href":"https://api.github.com/repos/Vestorly/torii/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Vestorly/torii/pulls/200/commits"},"statuses":{"href":"https://api.github.com/repos/Vestorly/torii/statuses/421a8188462b52a0349f6eff8741892a2cae2842"}}}}