I cannot establish why Ember Simple Auth isn't using the custom authoriser function authorise to add my token to the jQuery AJAX request headers.
I have followed the instructions in the documentation.
Here is my custom authoriser code:
/* Imports */
import Ember from 'ember';
import Base from 'simple-auth/authorizers/base';
/* Puddl Authorizer */
var Authorizer = Base.extend({
/* Authorize Outgoing Requests */
authorize: function(jqXHR/*, requestOptions*/) {
console.log('Authorize');
/* Add Token To jQuery Request */
jqXHR.setRequestHeader('Authorization', 'Token '+this.session.content.token);
},
init: function() {
}
});
/* Exports */
export default {
name: 'Authorizer',
before: 'simple-auth',
initialize: function(Container) {
Container.register('authorizer:custom', Authorizer);
};
I have added the following to the environment config file:
ENV['simple-auth'] = {
authorizer: 'authorizer:custom',
store: 'simple-auth-session-store:local-storage',
crossOriginWhitelist: [
'http://localhost/'
]
};
Can anybody help me work this out?
Aucun commentaire:
Enregistrer un commentaire