简体   繁体   中英

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":"f4f49eed1ddc43254c8a"}.

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!

The authenticator refers to which type of authenticator (token or JWT) should be used.

If you aren't using JWT tokens, then this issue is relevant to you: https://github.com/jpadilla/ember-simple-auth-token/issues/151

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM