Don't disable the Sign In button in the sign in modal

This commit is contained in:
Neil Lalonde 2014-06-13 16:07:18 -04:00
parent 3c8a610f73
commit c1f9d76323
2 changed files with 20 additions and 11 deletions

View File

@ -33,8 +33,8 @@ export default Discourse.Controller.extend(Discourse.ModalFunctionality, {
}.property('loggingIn'),
loginDisabled: function() {
return this.get('loggingIn') || this.blank('loginName') || this.blank('loginPassword');
}.property('loginName', 'loginPassword', 'loggingIn'),
return this.get('loggingIn');
}.property('loggingIn'),
showSignupLink: function() {
return !Discourse.SiteSettings.invite_only && !this.get('loggingIn') && this.blank('authenticate');
@ -46,37 +46,45 @@ export default Discourse.Controller.extend(Discourse.ModalFunctionality, {
actions: {
login: function() {
if (this.blank('loginName') || this.blank('loginPassword')) {
this.flash(I18n.t('login.blank_username_or_password'), 'error');
return false;
}
this.set('loggingIn', true);
var loginController = this;
var self = this;
Discourse.ajax("/session", {
data: { login: this.get('loginName'), password: this.get('loginPassword') },
type: 'POST'
}).then(function (result) {
// Successful login
if (result.error) {
loginController.set('loggingIn', false);
self.set('loggingIn', false);
if( result.reason === 'not_activated' ) {
loginController.send('showNotActivated', {
username: loginController.get('loginName'),
self.send('showNotActivated', {
username: self.get('loginName'),
sentTo: result.sent_to_email,
currentEmail: result.current_email
});
}
loginController.flash(result.error, 'error');
self.flash(result.error, 'error');
} else {
// Trigger the browser's password manager using the hidden static login form:
var $hidden_login_form = $('#hidden-login-form');
$hidden_login_form.find('input[name=username]').val(loginController.get('loginName'));
$hidden_login_form.find('input[name=password]').val(loginController.get('loginPassword'));
$hidden_login_form.find('input[name=username]').val(self.get('loginName'));
$hidden_login_form.find('input[name=password]').val(self.get('loginPassword'));
$hidden_login_form.find('input[name=redirect]').val(window.location.href);
$hidden_login_form.submit();
}
}, function() {
// Failed to login
loginController.flash(I18n.t('login.error'), 'error');
loginController.set('loggingIn', false);
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.set('loggingIn', false);
});
return false;

View File

@ -507,6 +507,7 @@ en:
password: "Password"
email_placeholder: "email or username"
error: "Unknown error"
blank_username_or_password: "Please enter your email or username, and password."
reset_password: 'Reset Password'
logging_in: "Signing In..."
or: "Or"