{"action":"created","comment":{"url":"https://api.github.com/repos/simplabs/ember-simple-auth/pulls/comments/58336556","id":58336556,"diff_hunk":"@@ -0,0 +1,60 @@\n+import Ember from 'ember';\n+\n+const { service } = Ember.inject;\n+\n+/**\n+\n+  __The `DeviseTokenAuthDataAdapterMixin` will update the session store with the new\n+  access-tokens and expiry after each call. It will also invalidate the session whenever it\n+  receives a 401 response for an API request.__\n+\n+  __This mixin must be used in conjunction with DataAdapterMixin so the other standard\n+  methods are run properly.__\n+\n+  ```js\n+  // app/adapters/application.js\n+  import DS from 'ember-data';\n+  import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';\n+  import DeviseTokenAuthDataAdapterMixin from 'ember-simple-auth/mixins/devise-token-auth-data-adapter-mixin';\n+\n+  export default DS.JSONAPIAdapter.extend(DeviseTokenAuthDataAdapterMixin, DataAdapterMixin, {\n+    authorizer: 'authorizer:devise-token-auth'\n+  });\n+  ```\n+\n+  __The `DeviseTokenAuthDataAdapterMixin` requires Ember Data 1.13 or later.__\n+\n+  @class DeviseTokenAuthDataAdapterMixin\n+  @module ember-simple-auth/mixins/devise-token-auth-data-adapter-mixin\n+  @extends Ember.Mixin\n+  @public\n+*/\n+\n+export default Ember.Mixin.create({\n+  /**\n+    This method is called for every response that the adapter receives from the\n+    API. If the response has a 401 status code it invalidates the session (see\n+    {{#crossLink \"SessionService/invalidate:method\"}}{{/crossLink}}).\n+\n+    @method handleResponse\n+    @param {Number} status The response status as received from the API\n+    @param {Array} headers The response headers as received from the API\n+    @protected\n+  */\n+  handleResponse(status, headers) {\n+    if ((status === 401 && this.get('session.isAuthenticated'))\n+        || (this.get('session.data.authenticated.uid') != headers['uid'] || this.get('session.data.authenticated.client') != headers['client'] )","path":"addon/mixins/devise-token-auth-data-adapter-mixin.js","position":46,"original_position":46,"commit_id":"190742aa782e8800e22480433786438d2a8e8bef","original_commit_id":"190742aa782e8800e22480433786438d2a8e8bef","user":{"login":"marcoow","id":1510,"avatar_url":"https://avatars.githubusercontent.com/u/1510?v=3","gravatar_id":"","url":"https://api.github.com/users/marcoow","html_url":"https://github.com/marcoow","followers_url":"https://api.github.com/users/marcoow/followers","following_url":"https://api.github.com/users/marcoow/following{/other_user}","gists_url":"https://api.github.com/users/marcoow/gists{/gist_id}","starred_url":"https://api.github.com/users/marcoow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcoow/subscriptions","organizations_url":"https://api.github.com/users/marcoow/orgs","repos_url":"https://api.github.com/users/marcoow/repos","events_url":"https://api.github.com/users/marcoow/events{/privacy}","received_events_url":"https://api.github.com/users/marcoow/received_events","type":"User","site_admin":false},"body":"The session data shouldn't be modified from outside of the session/authenticator actually. There would have to be a better way/public API to do things like this if this is required.","created_at":"2016-04-04T07:22:52Z","updated_at":"2016-04-04T07:22:52Z","html_url":"https://github.com/simplabs/ember-simple-auth/pull/946#discussion_r58336556","pull_request_url":"https://api.github.com/repos/simplabs/ember-simple-auth/pulls/946","_links":{"self":{"href":"https://api.github.com/repos/simplabs/ember-simple-auth/pulls/comments/58336556"},"html":{"href":"https://github.com/simplabs/ember-simple-auth/pull/946#discussion_r58336556"},"pull_request":{"href":"https://api.github.com/repos/simplabs/ember-simple-auth/pulls/946"}}},"pull_request":{"url":"https://api.github.com/repos/simplabs/ember-simple-auth/pulls/946","id":65032421,"html_url":"https://github.com/simplabs/ember-simple-auth/pull/946","diff_url":"https://github.com/simplabs/ember-simple-auth/pull/946.diff","patch_url":"https://github.com/simplabs/ember-simple-auth/pull/946.patch","issue_url":"https://api.github.com/repos/simplabs/ember-simple-auth/issues/946","number":946,"state":"open","locked":false,"title":"Added Authenticator and Authoriser to support devise-token-auth","user":{"login":"jaijaz","id":500976,"avatar_url":"https://avatars.githubusercontent.com/u/500976?v=3","gravatar_id":"","url":"https://api.github.com/users/jaijaz","html_url":"https://github.com/jaijaz","followers_url":"https://api.github.com/users/jaijaz/followers","following_url":"https://api.github.com/users/jaijaz/following{/other_user}","gists_url":"https://api.github.com/users/jaijaz/gists{/gist_id}","starred_url":"https://api.github.com/users/jaijaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaijaz/subscriptions","organizations_url":"https://api.github.com/users/jaijaz/orgs","repos_url":"https://api.github.com/users/jaijaz/repos","events_url":"https://api.github.com/users/jaijaz/events{/privacy}","received_events_url":"https://api.github.com/users/jaijaz/received_events","type":"User","site_admin":false},"body":"I'm not sure what your plans are in terms of extending ember-simple-auth with alternate server side authentication methods, but since you have a devise one currently, and devise gives devise-token-auth as an alternative now that it has removed token auth from it's repo, I thought I would offer you this PR in case you wanted to include it.\r\n\r\nPerhaps however you would prefer to have addons that use ember-simple-auth as dependancy?\r\n\r\nIn case you do wish to use this, it is all relatively straight forward. There is a new mixin that overrides the standard one for the data adaptors to allow for updating the access-token and expiry after every call. It does however have a hack in there to force the update of the session data as documented in issue #375.","created_at":"2016-04-02T08:47:14Z","updated_at":"2016-04-04T07:22:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cb143df671235a460952e4ccd76563245516d711","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/simplabs/ember-simple-auth/pulls/946/commits","review_comments_url":"https://api.github.com/repos/simplabs/ember-simple-auth/pulls/946/comments","review_comment_url":"https://api.github.com/repos/simplabs/ember-simple-auth/pulls/comments{/number}","comments_url":"https://api.github.com/repos/simplabs/ember-simple-auth/issues/946/comments","statuses_url":"https://api.github.com/repos/simplabs/ember-simple-auth/statuses/190742aa782e8800e22480433786438d2a8e8bef","head":{"label":"BebopTech:master","ref":"master","sha":"190742aa782e8800e22480433786438d2a8e8bef","user":{"login":"BebopTech","id":18082680,"avatar_url":"https://avatars.githubusercontent.com/u/18082680?v=3","gravatar_id":"","url":"https://api.github.com/users/BebopTech","html_url":"https://github.com/BebopTech","followers_url":"https://api.github.com/users/BebopTech/followers","following_url":"https://api.github.com/users/BebopTech/following{/other_user}","gists_url":"https://api.github.com/users/BebopTech/gists{/gist_id}","starred_url":"https://api.github.com/users/BebopTech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BebopTech/subscriptions","organizations_url":"https://api.github.com/users/BebopTech/orgs","repos_url":"https://api.github.com/users/BebopTech/repos","events_url":"https://api.github.com/users/BebopTech/events{/privacy}","received_events_url":"https://api.github.com/users/BebopTech/received_events","type":"Organization","site_admin":false},"repo":{"id":54767453,"name":"ember-simple-auth","full_name":"BebopTech/ember-simple-auth","owner":{"login":"BebopTech","id":18082680,"avatar_url":"https://avatars.githubusercontent.com/u/18082680?v=3","gravatar_id":"","url":"https://api.github.com/users/BebopTech","html_url":"https://github.com/BebopTech","followers_url":"https://api.github.com/users/BebopTech/followers","following_url":"https://api.github.com/users/BebopTech/following{/other_user}","gists_url":"https://api.github.com/users/BebopTech/gists{/gist_id}","starred_url":"https://api.github.com/users/BebopTech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BebopTech/subscriptions","organizations_url":"https://api.github.com/users/BebopTech/orgs","repos_url":"https://api.github.com/users/BebopTech/repos","events_url":"https://api.github.com/users/BebopTech/events{/privacy}","received_events_url":"https://api.github.com/users/BebopTech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BebopTech/ember-simple-auth","description":"A library for implementing authentication/authorization in Ember.js applications.","fork":true,"url":"https://api.github.com/repos/BebopTech/ember-simple-auth","forks_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/forks","keys_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/teams","hooks_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/hooks","issue_events_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/issues/events{/number}","events_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/events","assignees_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/assignees{/user}","branches_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/branches{/branch}","tags_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/tags","blobs_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/git/refs{/sha}","trees_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/statuses/{sha}","languages_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/languages","stargazers_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/stargazers","contributors_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/contributors","subscribers_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/subscribers","subscription_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/subscription","commits_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/commits{/sha}","git_commits_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/git/commits{/sha}","comments_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/comments{/number}","issue_comment_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/issues/comments{/number}","contents_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/contents/{+path}","compare_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/merges","archive_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/downloads","issues_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/issues{/number}","pulls_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/pulls{/number}","milestones_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/milestones{/number}","notifications_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/labels{/name}","releases_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/releases{/id}","deployments_url":"https://api.github.com/repos/BebopTech/ember-simple-auth/deployments","created_at":"2016-03-26T07:06:52Z","updated_at":"2016-03-26T07:06:53Z","pushed_at":"2016-04-02T08:37:42Z","git_url":"git://github.com/BebopTech/ember-simple-auth.git","ssh_url":"git@github.com:BebopTech/ember-simple-auth.git","clone_url":"https://github.com/BebopTech/ember-simple-auth.git","svn_url":"https://github.com/BebopTech/ember-simple-auth","homepage":"http://ember-simple-auth.com","size":7187,"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":"simplabs:master","ref":"master","sha":"bed56395e8ce0e376e28b6ea9a62a4e26585d875","user":{"login":"simplabs","id":56627,"avatar_url":"https://avatars.githubusercontent.com/u/56627?v=3","gravatar_id":"","url":"https://api.github.com/users/simplabs","html_url":"https://github.com/simplabs","followers_url":"https://api.github.com/users/simplabs/followers","following_url":"https://api.github.com/users/simplabs/following{/other_user}","gists_url":"https://api.github.com/users/simplabs/gists{/gist_id}","starred_url":"https://api.github.com/users/simplabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simplabs/subscriptions","organizations_url":"https://api.github.com/users/simplabs/orgs","repos_url":"https://api.github.com/users/simplabs/repos","events_url":"https://api.github.com/users/simplabs/events{/privacy}","received_events_url":"https://api.github.com/users/simplabs/received_events","type":"Organization","site_admin":false},"repo":{"id":12570984,"name":"ember-simple-auth","full_name":"simplabs/ember-simple-auth","owner":{"login":"simplabs","id":56627,"avatar_url":"https://avatars.githubusercontent.com/u/56627?v=3","gravatar_id":"","url":"https://api.github.com/users/simplabs","html_url":"https://github.com/simplabs","followers_url":"https://api.github.com/users/simplabs/followers","following_url":"https://api.github.com/users/simplabs/following{/other_user}","gists_url":"https://api.github.com/users/simplabs/gists{/gist_id}","starred_url":"https://api.github.com/users/simplabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simplabs/subscriptions","organizations_url":"https://api.github.com/users/simplabs/orgs","repos_url":"https://api.github.com/users/simplabs/repos","events_url":"https://api.github.com/users/simplabs/events{/privacy}","received_events_url":"https://api.github.com/users/simplabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/simplabs/ember-simple-auth","description":"A library for implementing authentication/authorization in Ember.js applications.","fork":false,"url":"https://api.github.com/repos/simplabs/ember-simple-auth","forks_url":"https://api.github.com/repos/simplabs/ember-simple-auth/forks","keys_url":"https://api.github.com/repos/simplabs/ember-simple-auth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simplabs/ember-simple-auth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simplabs/ember-simple-auth/teams","hooks_url":"https://api.github.com/repos/simplabs/ember-simple-auth/hooks","issue_events_url":"https://api.github.com/repos/simplabs/ember-simple-auth/issues/events{/number}","events_url":"https://api.github.com/repos/simplabs/ember-simple-auth/events","assignees_url":"https://api.github.com/repos/simplabs/ember-simple-auth/assignees{/user}","branches_url":"https://api.github.com/repos/simplabs/ember-simple-auth/branches{/branch}","tags_url":"https://api.github.com/repos/simplabs/ember-simple-auth/tags","blobs_url":"https://api.github.com/repos/simplabs/ember-simple-auth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simplabs/ember-simple-auth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simplabs/ember-simple-auth/git/refs{/sha}","trees_url":"https://api.github.com/repos/simplabs/ember-simple-auth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simplabs/ember-simple-auth/statuses/{sha}","languages_url":"https://api.github.com/repos/simplabs/ember-simple-auth/languages","stargazers_url":"https://api.github.com/repos/simplabs/ember-simple-auth/stargazers","contributors_url":"https://api.github.com/repos/simplabs/ember-simple-auth/contributors","subscribers_url":"https://api.github.com/repos/simplabs/ember-simple-auth/subscribers","subscription_url":"https://api.github.com/repos/simplabs/ember-simple-auth/subscription","commits_url":"https://api.github.com/repos/simplabs/ember-simple-auth/commits{/sha}","git_commits_url":"https://api.github.com/repos/simplabs/ember-simple-auth/git/commits{/sha}","comments_url":"https://api.github.com/repos/simplabs/ember-simple-auth/comments{/number}","issue_comment_url":"https://api.github.com/repos/simplabs/ember-simple-auth/issues/comments{/number}","contents_url":"https://api.github.com/repos/simplabs/ember-simple-auth/contents/{+path}","compare_url":"https://api.github.com/repos/simplabs/ember-simple-auth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simplabs/ember-simple-auth/merges","archive_url":"https://api.github.com/repos/simplabs/ember-simple-auth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simplabs/ember-simple-auth/downloads","issues_url":"https://api.github.com/repos/simplabs/ember-simple-auth/issues{/number}","pulls_url":"https://api.github.com/repos/simplabs/ember-simple-auth/pulls{/number}","milestones_url":"https://api.github.com/repos/simplabs/ember-simple-auth/milestones{/number}","notifications_url":"https://api.github.com/repos/simplabs/ember-simple-auth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simplabs/ember-simple-auth/labels{/name}","releases_url":"https://api.github.com/repos/simplabs/ember-simple-auth/releases{/id}","deployments_url":"https://api.github.com/repos/simplabs/ember-simple-auth/deployments","created_at":"2013-09-03T18:03:26Z","updated_at":"2016-04-03T12:06:16Z","pushed_at":"2016-04-02T13:56:06Z","git_url":"git://github.com/simplabs/ember-simple-auth.git","ssh_url":"git@github.com:simplabs/ember-simple-auth.git","clone_url":"https://github.com/simplabs/ember-simple-auth.git","svn_url":"https://github.com/simplabs/ember-simple-auth","homepage":"http://ember-simple-auth.com","size":8623,"stargazers_count":1390,"watchers_count":1390,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":378,"mirror_url":null,"open_issues_count":46,"forks":378,"open_issues":46,"watchers":1390,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/simplabs/ember-simple-auth/pulls/946"},"html":{"href":"https://github.com/simplabs/ember-simple-auth/pull/946"},"issue":{"href":"https://api.github.com/repos/simplabs/ember-simple-auth/issues/946"},"comments":{"href":"https://api.github.com/repos/simplabs/ember-simple-auth/issues/946/comments"},"review_comments":{"href":"https://api.github.com/repos/simplabs/ember-simple-auth/pulls/946/comments"},"review_comment":{"href":"https://api.github.com/repos/simplabs/ember-simple-auth/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/simplabs/ember-simple-auth/pulls/946/commits"},"statuses":{"href":"https://api.github.com/repos/simplabs/ember-simple-auth/statuses/190742aa782e8800e22480433786438d2a8e8bef"}}}}