I'm trying to handle an error messages with Ember Simple Auth, I'm using the devise extension.
File: app/controllers/login.js
import Ember from 'ember';
import LoginControllerMixin from 'simple-auth/mixins/login-controller-mixin';
export default Ember.Controller.extend(LoginControllerMixin, {
authenticator: 'simple-auth-authenticator:devise',
identification: null,
password: null,
loginError: false,
isSubmitting: false,
actions: {
authenticate: function() {
var data = this.getProperties('identification', 'password');
this._super(data);
this.set('password', null);
this.setProperties({
loginError: true,
loginResponse: 'login error'
});
}
}
});
At the moment I always get the error message. I don't know how to show it only when an error occur. I have tried with
this._super(data).then(function({
// Error handler
});
But then I get the error "_super() is undefined".
In the above code you're always setting the error regardless of whether login is successful or not. What you would have to do is trigger the session authentication yourself:
this.get('session').authenticate(this.get('authenticator'), data).then(function() {
…//success
}, function(error) {
…//error
});