Updated translation support
This commit is contained in:
parent
b1e8cd68cd
commit
d25565b6f8
114 changed files with 42095 additions and 1902 deletions
|
@ -9,6 +9,7 @@ let mailer = require('../mailer');
|
|||
let settings = require('./settings');
|
||||
let crypto = require('crypto');
|
||||
let urllib = require('url');
|
||||
let _ = require('../translate')._;
|
||||
|
||||
/**
|
||||
* Fetches user by ID value
|
||||
|
@ -99,7 +100,7 @@ module.exports.add = (username, password, email, callback) => {
|
|||
|
||||
let id = result && result.insertId;
|
||||
if (!id) {
|
||||
return callback(new Error('Could not store user row'));
|
||||
return callback(new Error(_('Could not store user row')));
|
||||
}
|
||||
|
||||
return callback(null, id);
|
||||
|
@ -169,7 +170,7 @@ module.exports.authenticate = (username, password, callback) => {
|
|||
module.exports.update = (id, updates, callback) => {
|
||||
|
||||
if (!updates.email) {
|
||||
return callback(new Error('Email Address must be set'));
|
||||
return callback(new Error(_('Email Address must be set')));
|
||||
}
|
||||
|
||||
let update = (connection, callback) => {
|
||||
|
@ -180,7 +181,7 @@ module.exports.update = (id, updates, callback) => {
|
|||
}
|
||||
|
||||
if (!rows.length) {
|
||||
return callback('Failed to check user data');
|
||||
return callback(_('Failed to check user data'));
|
||||
}
|
||||
|
||||
let keys = ['email'];
|
||||
|
@ -191,7 +192,7 @@ module.exports.update = (id, updates, callback) => {
|
|||
connection.query('UPDATE users SET ' + keys.map(key => key + '=?').join(', ') + ' WHERE id=? LIMIT 1', values, (err, result) => {
|
||||
if (err) {
|
||||
if (err.code === 'ER_DUP_ENTRY') {
|
||||
err = new Error('Can\'t change email as another user with the same email address already exists');
|
||||
err = new Error(_('Can\'t change email as another user with the same email address already exists'));
|
||||
}
|
||||
return callback(err);
|
||||
}
|
||||
|
@ -208,15 +209,15 @@ module.exports.update = (id, updates, callback) => {
|
|||
return callback(err);
|
||||
}
|
||||
if (!result) {
|
||||
return callback('Incorrect current password');
|
||||
return callback(_('Incorrect current password'));
|
||||
}
|
||||
|
||||
if (!updates.password) {
|
||||
return callback(new Error('New password not set'));
|
||||
return callback(new Error(_('New password not set')));
|
||||
}
|
||||
|
||||
if (updates.password !== updates.password2) {
|
||||
return callback(new Error('Passwords do not match'));
|
||||
return callback(new Error(_('Passwords do not match')));
|
||||
}
|
||||
|
||||
bcrypt.hash(updates.password, null, null, (err, hash) => {
|
||||
|
@ -254,7 +255,7 @@ module.exports.resetToken = (id, callback) => {
|
|||
id = Number(id) || 0;
|
||||
|
||||
if (!id) {
|
||||
return callback(new Error('User ID not set'));
|
||||
return callback(new Error(_('User ID not set')));
|
||||
}
|
||||
|
||||
db.getConnection((err, connection) => {
|
||||
|
@ -282,7 +283,7 @@ module.exports.sendReset = (username, callback) => {
|
|||
username = (username || '').toString().trim();
|
||||
|
||||
if (!username) {
|
||||
return callback(new Error('Username must be set'));
|
||||
return callback(new Error(_('Username must be set')));
|
||||
}
|
||||
|
||||
db.getConnection((err, connection) => {
|
||||
|
@ -319,7 +320,7 @@ module.exports.sendReset = (username, callback) => {
|
|||
to: {
|
||||
address: rows[0].email
|
||||
},
|
||||
subject: 'Mailer password change request'
|
||||
subject: _('Mailer password change request')
|
||||
}, {
|
||||
html: 'emails/password-reset-html.hbs',
|
||||
text: 'emails/password-reset-text.hbs',
|
||||
|
@ -343,7 +344,7 @@ module.exports.sendReset = (username, callback) => {
|
|||
|
||||
module.exports.checkResetToken = (username, resetToken, callback) => {
|
||||
if (!username || !resetToken) {
|
||||
return callback(new Error('Missing username or reset token'));
|
||||
return callback(new Error(_('Missing username or reset token')));
|
||||
}
|
||||
db.getConnection((err, connection) => {
|
||||
if (err) {
|
||||
|
@ -363,11 +364,11 @@ module.exports.resetPassword = (data, callback) => {
|
|||
let updates = tools.convertKeys(data);
|
||||
|
||||
if (!updates.username || !updates.resetToken) {
|
||||
return callback(new Error('Missing username or reset token'));
|
||||
return callback(new Error(_('Missing username or reset token')));
|
||||
}
|
||||
|
||||
if (!updates.password || !updates.password2 || updates.password !== updates.password2) {
|
||||
return callback(new Error('Invalid new password'));
|
||||
return callback(new Error(_('Invalid new password')));
|
||||
}
|
||||
|
||||
bcrypt.hash(updates.password, null, null, (err, hash) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue