Node.js based forum software built for the modern web
language keys for password changing -- issue #1278
Julian Lambc29f832fe44
diff --git a/public/language/en_GB/user.json b/public/language/en_GB/user.jsonindex 513d001736..2363b1d09e 100644--- a/public/language/en_GB/user.json+++ b/public/language/en_GB/user.json@@ -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",diff --git a/public/src/forum/accountedit.js b/public/src/forum/accountedit.jsindex 515e1d4047..701c97ff74 100644--- a/public/src/forum/accountedit.js+++ b/public/src/forum/accountedit.js@@ -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;diff --git a/public/src/forum/register.js b/public/src/forum/register.jsindex 6d189cdad3..871c199239 100644--- a/public/src/forum/register.js+++ b/public/src/forum/register.js@@ -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);}diff --git a/src/user/profile.js b/src/user/profile.jsindex e1fc6284d4..50a33112e5 100644--- a/src/user/profile.js+++ b/src/user/profile.js@@ -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);});