0

I've just finished upgrading my app to use the jj-abrams branch of ember-simple-auth (soon to be 1.0).

It's working great when I use ember data but, for one route, I use Ember.$.getJSON to retrieve chart data directly from the server.

In this instance, the authorization header is missing from the request and I'm guessing that's because it doesn't use the application adapter (therefore bypassing authorizer: 'authorizer:devise')?

Is there a way to add this header manually, or a better way to make this request?

Joe Czucha
  • 4,123
  • 2
  • 20
  • 28

1 Answers1

0

Sure you can just include the session then you should have access to the credentials and use whatever you need to add those to your Router (I'm assuming it's using the AuthenticatedRouteMixin on your router.

Or for your controller add:

session: Ember.inject.service('session')

then you can do a get:

this.get('session') 

and examine the object to find what you need in there, I believe that should make it easier for you to run without using Ember-Data.

Dory Zidon
  • 10,497
  • 2
  • 25
  • 39
  • Am I correct in thinking that you can only inject the service into a controller and not a route? – Joe Czucha Oct 15 '15 at 20:09
  • you can inject the session service into anything you want. You can call the session service's `authorize` method to authorize AJAX requests then: http://ember-simple-auth.com/api/classes/SessionService.html#method_authorize – marcoow Oct 15 '15 at 20:10
  • yep marcoow, that you can do, authorize only adds the token to the ajax call, so you can use that to add your headers. that's what I did in my projects. – Dory Zidon Oct 15 '15 at 20:11