-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adopt ember-simple-auth auth recommendations
Authentication header are now passed as query-params instead of xhr as suggested in the following documentations -> mainmatter/ember-simple-auth#1994 It also affects the load of the current user as suggested here: -> https://github.com/simplabs/ember-simple-auth/blob/master/guides/managing-current-user.md#loading-the-current-user
- Loading branch information
1 parent
ce7e342
commit db1a357
Showing
5 changed files
with
25 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import DS from 'ember-data'; | ||
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin'; | ||
import { isPresent } from '@ember/utils'; | ||
import { computed } from '@ember/object'; | ||
import ENV from 'mon-pix/config/environment'; | ||
|
||
export default DS.JSONAPIAdapter.extend(DataAdapterMixin, { | ||
host: ENV.APP.API_HOST, | ||
namespace: 'api', | ||
|
||
authorize(xhr) { | ||
const { access_token } = this.get('session.data.authenticated'); | ||
if (isPresent(access_token)) { | ||
xhr.setRequestHeader('Authorization', `Bearer ${access_token}`); | ||
headers: computed('session.data.authenticated.access_token', function() { | ||
const headers = {}; | ||
if (this.session.isAuthenticated) { | ||
headers['Authorization'] = `Bearer ${this.session.data.authenticated.access_token}`; | ||
} | ||
} | ||
return headers; | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters