mercredi 6 avril 2016

Ember simple auth token authenticator

I am new to Ember and I'd like to use ember simple-auth library along with ember simple-auth-token. My problem is that I can't understand what to put in the authenticator variable. The code below is taken from the simple-auth-token readme on github.

// app/controllers/login.js
import Ember from 'ember';

export default Ember.Controller.extend({
  session: Ember.inject.service(),

  actions: {
      authenticate: function() {
        var credentials = this.getProperties('identification', 'password'),
        authenticator = 'authenticator:token';

        this.get('session').authenticate(authenticator, credentials);
      } 
  }
});

My server responds with a token that looks pretty much like this: {"auth_token":"f4f49eed1ddc43254c8af4f49eed1ddc43254c8a"}.

Should I change 'authenticator:token' to 'authenticator:auth_token'? How exactly will the token value be passed to the authenticator?

Thanks in advance for your help!




Aucun commentaire:

Enregistrer un commentaire