mercredi 20 janvier 2016

What is ember-simple-auth "password grant" authentiator expect from server?

I am confused. What does "password_grant" type of authenticator expect from server for it to say "successfully" authenticated when it is trying to get its token from remote server?

It seems as long as server return 200 status code, it always authenticated. Am I missing something here?

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

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

  actions: {
    authenticate() {
      let { identification, password } = this.getProperties('identification', 'password');
      this.get('session').authenticate('authenticator:oauth2', identification, password).catch((reason) => {
        this.set('errorMessage', reason.error || reason);
      });
    }
  }
});

The promise.then part indicates a successful authentication? If so, how to fall into the error part(unauthenticated)? I tried to return {"error":"something"} from server, but it's still authenticated.




Aucun commentaire:

Enregistrer un commentaire