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);
});
}
}
});
If the user password didn't pass authentication on the server side, the server should return 401 status code?
More: Based on this, server should response with 400.
So, based on what I have researched, once server return 200 code and some JSON data, even any empty JSON data, ember-simple-auth will take it as authenticated. Returning 400 will fall into the catch clause.
Maybe someone can just comfirm with me on this? I guess oauth2.0 is supposed to be implemented on the server side. Ember-simple-auth simply just comply to the standard and assume that "200 status code" means authenticated and token should be inside the json payload returned.