mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 18:24:52 -06:00
Don't disable the Sign In button in the sign in modal
This commit is contained in:
parent
3c8a610f73
commit
c1f9d76323
@ -33,8 +33,8 @@ export default Discourse.Controller.extend(Discourse.ModalFunctionality, {
|
|||||||
}.property('loggingIn'),
|
}.property('loggingIn'),
|
||||||
|
|
||||||
loginDisabled: function() {
|
loginDisabled: function() {
|
||||||
return this.get('loggingIn') || this.blank('loginName') || this.blank('loginPassword');
|
return this.get('loggingIn');
|
||||||
}.property('loginName', 'loginPassword', 'loggingIn'),
|
}.property('loggingIn'),
|
||||||
|
|
||||||
showSignupLink: function() {
|
showSignupLink: function() {
|
||||||
return !Discourse.SiteSettings.invite_only && !this.get('loggingIn') && this.blank('authenticate');
|
return !Discourse.SiteSettings.invite_only && !this.get('loggingIn') && this.blank('authenticate');
|
||||||
@ -46,37 +46,45 @@ export default Discourse.Controller.extend(Discourse.ModalFunctionality, {
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
login: function() {
|
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);
|
this.set('loggingIn', true);
|
||||||
|
|
||||||
var loginController = this;
|
var self = this;
|
||||||
Discourse.ajax("/session", {
|
Discourse.ajax("/session", {
|
||||||
data: { login: this.get('loginName'), password: this.get('loginPassword') },
|
data: { login: this.get('loginName'), password: this.get('loginPassword') },
|
||||||
type: 'POST'
|
type: 'POST'
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
// Successful login
|
// Successful login
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
loginController.set('loggingIn', false);
|
self.set('loggingIn', false);
|
||||||
if( result.reason === 'not_activated' ) {
|
if( result.reason === 'not_activated' ) {
|
||||||
loginController.send('showNotActivated', {
|
self.send('showNotActivated', {
|
||||||
username: loginController.get('loginName'),
|
username: self.get('loginName'),
|
||||||
sentTo: result.sent_to_email,
|
sentTo: result.sent_to_email,
|
||||||
currentEmail: result.current_email
|
currentEmail: result.current_email
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
loginController.flash(result.error, 'error');
|
self.flash(result.error, 'error');
|
||||||
} else {
|
} else {
|
||||||
// Trigger the browser's password manager using the hidden static login form:
|
// Trigger the browser's password manager using the hidden static login form:
|
||||||
var $hidden_login_form = $('#hidden-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=username]').val(self.get('loginName'));
|
||||||
$hidden_login_form.find('input[name=password]').val(loginController.get('loginPassword'));
|
$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.find('input[name=redirect]').val(window.location.href);
|
||||||
$hidden_login_form.submit();
|
$hidden_login_form.submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
}, function() {
|
}, function() {
|
||||||
// Failed to login
|
// Failed to login
|
||||||
loginController.flash(I18n.t('login.error'), 'error');
|
if (self.blank('loginName') || self.blank('loginPassword')) {
|
||||||
loginController.set('loggingIn', false);
|
self.flash(I18n.t('login.blank_username_or_password'), 'error');
|
||||||
|
} else {
|
||||||
|
self.flash(I18n.t('login.error'), 'error');
|
||||||
|
}
|
||||||
|
self.set('loggingIn', false);
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -507,6 +507,7 @@ en:
|
|||||||
password: "Password"
|
password: "Password"
|
||||||
email_placeholder: "email or username"
|
email_placeholder: "email or username"
|
||||||
error: "Unknown error"
|
error: "Unknown error"
|
||||||
|
blank_username_or_password: "Please enter your email or username, and password."
|
||||||
reset_password: 'Reset Password'
|
reset_password: 'Reset Password'
|
||||||
logging_in: "Signing In..."
|
logging_in: "Signing In..."
|
||||||
or: "Or"
|
or: "Or"
|
||||||
|
Loading…
Reference in New Issue
Block a user