I have my custom authorizer file that looks like this but is not working,
import Ember from 'ember';
import Base from 'ember-simple-auth/authorizers/base';
export default Base.extend({
authorize: function(jqXHR, requestOptions) {
var accessToken = this.get('session.content.secure.token');
if (this.get('session.isAuthenticated') && !Ember.isEmpty(accessToken)) {
jqXHR.setRequestHeader('Authorization', 'Bearer ' + accessToken);
}
}
});
After reviewing this post: http://ift.tt/1VKNt0O it is still not clear to me,here should I call the authorizer?? What about with the session store?? Please can someone can clarify this to me, I'm getting the error authorizer is undefined
my ajax call looks like this:
import Ember from 'ember';
export default Ember.Component.extend({
session: Ember.inject.service(),
gotQuote: false,
quote: "",
actions: {
getQuote: function() {
this.get('session').authorize('authorizer:cusmtom', (headerName, headerValue) => {
const headers = {};
headers[headerName] = headerValue;
var that = this;
Ember.$.ajax({
type: 'GET',
url: 'http://ift.tt/22xjedL',
headers: headers,
success: function(response) {
that.setProperties({
quote: response.quoteText,
gotQuote: true
});
},
error: function(xhr) {
alert('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
}
});
});
}
}
});
Aucun commentaire:
Enregistrer un commentaire