language keys for password changing -- issue #1278

v1.18.x
Julian Lam 11 years ago
parent 1abba25f83
commit bc29f832fe

@ -31,6 +31,12 @@
"upload_new_picture": "Upload New Picture",
"current_password": "Current Password",
"change_password": "Change Password",
"change_password_error": "Invalid Password!",
"change_password_error_wrong_current": "Your current password is not correct!",
"change_password_error_length": "Password too short!",
"change_password_error_match": "Passwords must match!",
"change_password_error_privileges": "You are not have the rights to change this password.",
"change_password_success": "Your password is updated!",
"confirm_password": "Confirm Password",
"password": "Password",

@ -135,20 +135,24 @@ define(['forum/accountheader', 'uploader'], function(header, uploader) {
});
function showError(element, msg) {
element.html(msg);
element.parent()
.removeClass('alert-success')
.addClass('alert-danger');
element.show();
validationError = true;
translator.translate(msg, function(msg) {
element.html(msg);
element.parent()
.removeClass('alert-success')
.addClass('alert-danger');
element.show();
validationError = true;
});
}
function showSuccess(element, msg) {
element.html(msg);
element.parent()
.removeClass('alert-danger')
.addClass('alert-success');
element.show();
translator.translate(msg, function(msg) {
element.html(msg);
element.parent()
.removeClass('alert-danger')
.addClass('alert-success');
element.show();
});
}
(function handlePasswordChange() {
@ -165,9 +169,9 @@ define(['forum/accountheader', 'uploader'], function(header, uploader) {
function onPasswordChanged() {
passwordvalid = utils.isPasswordValid(password.val());
if (password.val().length < config.minimumPasswordLength) {
showError(password_notify, 'Password too short!');
showError(password_notify, '[[user:change_password_error_length]]');
} else if (!passwordvalid) {
showError(password_notify, 'Invalid password!');
showError(password_notify, '[[user:change_password_error]]');
} else {
showSuccess(password_notify, successIcon);
}
@ -176,7 +180,7 @@ define(['forum/accountheader', 'uploader'], function(header, uploader) {
function onPasswordConfirmChanged() {
if(password.val()) {
if (password.val() !== password_confirm.val()) {
showError(password_confirm_notify, 'Passwords must match!')
showError(password_confirm_notify, '[[user:change_password_error_match]]')
passwordsmatch = false;
} else {
showSuccess(password_confirm_notify, successIcon);
@ -195,7 +199,6 @@ define(['forum/accountheader', 'uploader'], function(header, uploader) {
'newPassword': password.val(),
'uid': ajaxify.variables.get('theirid')
}, function(err) {
currentPassword.val('');
password.val('');
password_confirm.val('');
@ -206,7 +209,7 @@ define(['forum/accountheader', 'uploader'], function(header, uploader) {
return app.alertError(err.message);
}
app.alertSuccess('Your password is updated!');
app.alertSuccess('[[user:change_password_success]]');
});
}
return false;

@ -9,20 +9,24 @@ define(function() {
successIcon = '<i class="fa fa-check"></i>';
function showError(element, msg) {
element.html(msg);
element.parent()
.removeClass('alert-success')
.addClass('alert-danger');
element.show();
validationError = true;
translator.translate(msg, function(msg) {
element.html(msg);
element.parent()
.removeClass('alert-success')
.addClass('alert-danger');
element.show();
validationError = true;
});
}
function showSuccess(element, msg) {
element.html(msg);
element.parent()
.removeClass('alert-danger')
.addClass('alert-success');
element.show();
translator.translate(msg, function(msg) {
element.html(msg);
element.parent()
.removeClass('alert-danger')
.addClass('alert-success');
element.show();
});
}
function validateEmail(email) {
@ -93,15 +97,15 @@ define(function() {
password_confirm_notify = $('#password-confirm-notify');
if (password.length < config.minimumPasswordLength) {
showError(password_notify, 'Password too short!');
showError(password_notify, '[[user:change_password_error_length]]');
} else if (!utils.isPasswordValid(password)) {
showError(password_notify, 'Invalid password!');
showError(password_notify, '[[user:change_password_error_]]');
} else {
showSuccess(password_notify, successIcon);
}
if (password !== password_confirm && password_confirm !== '') {
showError(password_confirm_notify, 'Passwords must match!');
showError(password_confirm_notify, '[[user:change_password_error_match]]');
}
}
@ -114,7 +118,7 @@ define(function() {
}
if (password !== password_confirm) {
showError(password_confirm_notify, 'Passwords must match!');
showError(password_confirm_notify, '[[user:change_password_error_match]]');
} else {
showSuccess(password_confirm_notify, successIcon);
}

@ -222,13 +222,13 @@ module.exports = function(User) {
}
if (!utils.isPasswordValid(data.newPassword)) {
return callback(new Error('Invalid password!'));
return callback(new Error('[[user:change_password_error]]'));
}
if(parseInt(uid, 10) !== parseInt(data.uid, 10)) {
User.isAdministrator(uid, function(err, isAdmin) {
if(err || !isAdmin) {
return callback(err || new Error('not-allowed'));
return callback(err || new Error('[[user:change_password_error_privileges'));
}
hashAndSetPassword(callback);
@ -245,7 +245,7 @@ module.exports = function(User) {
bcrypt.compare(data.currentPassword, currentPassword, function(err, res) {
if (err || !res) {
return callback(err || new Error('Your current password is not correct!'));
return callback(err || new Error('[[user:change_password_error_wrong_current]]'));
}
hashAndSetPassword(callback);
});

Loading…
Cancel
Save