Search code examples
ember.jsember-simple-auth

Missing ember-simple-auth authorization header when not using ember-data


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?


Solution

  • 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.