FIX: don't make an ajax request when password or user is blank

This commit is contained in:
Sam 2014-08-18 12:50:25 +10:00
parent ad1ae911f7
commit 24932009a5

View file

@ -45,9 +45,15 @@ export default DiscourseController.extend(ModalFunctionality, {
actions: {
login: function() {
var self = this;
if(this.blank('loginName') || this.blank('loginPassword')){
self.flash(I18n.t('login.blank_username_or_password'), 'error');
return;
}
this.set('loggingIn', true);
var self = this;
Discourse.ajax("/session", {
data: { login: this.get('loginName'), password: this.get('loginPassword') },
type: 'POST'
@ -75,11 +81,7 @@ export default DiscourseController.extend(ModalFunctionality, {
}, function() {
// Failed to login
if (self.blank('loginName') || self.blank('loginPassword')) {
self.flash(I18n.t('login.blank_username_or_password'), 'error');
} else {
self.flash(I18n.t('login.error'), 'error');
}
self.flash(I18n.t('login.error'), 'error');
self.set('loggingIn', false);
});