jeudi 4 juin 2015

Ember.js REST Auth Headers

I've been struggling with this for too long now. I have an Expressjs server that provides an endpoint to login. The response I get has a JWT token, expiring in an hour. All good.

On the Emberjs side, I can successfully authenticate and get the token (using ember-simple-auth and ember-simple-auth-token). This works well for protecting my routes. But I can't for the life of me update the RESTAdapter headers to include my new authorization token.

I've tried:

  • using $.ajaxPrefilter to set the Authorization header. Didn't work
  • accessing "this.get('session.secure.token')" from the RESTAdapter. Thats undefined.

Please, if someone could point me in the right direction, I'd be eternally grateful. All I need to do is attach the value in "session.secure.token" to the header for all RESTAdapter requests.

Thanks




Aucun commentaire:

Enregistrer un commentaire