mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
added lots of error keys
This commit is contained in:
@@ -8,10 +8,25 @@
|
||||
"invalid-pid": "Invalid Post ID",
|
||||
"invalid-uid": "Invalid User ID",
|
||||
|
||||
"invalid-username": "Invalid Username",
|
||||
"invalid-email": "Invalid Email",
|
||||
"invalid-title": "Invalid title",
|
||||
"invalid-user-data": "Invalid User Data",
|
||||
"invalid-password": "Invalid Password",
|
||||
|
||||
"invalid-pagination-value": "Invalid pagination value",
|
||||
|
||||
"username-taken": "Username taken",
|
||||
"email-taken": "Email taken",
|
||||
|
||||
"user-banned": "User banned",
|
||||
|
||||
"no-category": "Category doesn't exist",
|
||||
"no-topic": "Topic doesn't exist",
|
||||
"no-post": "Post doesn't exist",
|
||||
"no-group": "Group doesn't exist",
|
||||
"no-user": "User doesn't exist",
|
||||
"no-teaser": "Teaser doesn't exist",
|
||||
"no-privileges": "You don't have enough privileges for this action.",
|
||||
|
||||
"category-disabled": "Category disabled",
|
||||
@@ -35,5 +50,18 @@
|
||||
|
||||
"group-name-too-short": "Group name too short",
|
||||
"group-already-exists": "Group already exists",
|
||||
"group-name-change-not-allowed": "Group name change not allowed"
|
||||
"group-name-change-not-allowed": "Group name change not allowed",
|
||||
|
||||
"post-already-deleted": "Post already deleted",
|
||||
"post-already-restored": "Post already restored",
|
||||
|
||||
"topic-already-deleted": "Topic already deleted",
|
||||
"topic-already-restored": "Topic already restored",
|
||||
|
||||
|
||||
"topic-thumbnails-are-disabled": "Topic thumbnails are disabled.",
|
||||
"invalid-file": "Invalid File",
|
||||
"uploads-are-disabled": "Uploads are disabled",
|
||||
|
||||
"signature-too-long" : "Signature can't be longer than %1 characters!"
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"topic-post": "You have successfully posted."
|
||||
"topic-post": "You have successfully posted.",
|
||||
"authentication-successful": "Authentication Successful"
|
||||
|
||||
}
|
||||
@@ -120,7 +120,7 @@ var winston = require('winston'),
|
||||
|
||||
PostTools.privileges(pid, uid, function(err, privileges) {
|
||||
if (err || !privileges.editable) {
|
||||
return callback(err || new Error('not-privileges-to-edit'));
|
||||
return callback(err || new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
|
||||
posts.getPostData(pid, function(err, postData) {
|
||||
@@ -155,15 +155,15 @@ var winston = require('winston'),
|
||||
},
|
||||
function(deleted, next) {
|
||||
if(parseInt(deleted, 10) === 1 && isDelete) {
|
||||
return next(new Error('Post already deleted'));
|
||||
return next(new Error('[[error:post-already-deleted]]'));
|
||||
} else if(parseInt(deleted, 10) !== 1 && !isDelete) {
|
||||
return next(new Error('Post already restored'));
|
||||
return next(new Error('[[error:post-already-restored]]'));
|
||||
}
|
||||
PostTools.privileges(pid, uid, next);
|
||||
},
|
||||
function(privileges, next) {
|
||||
if (!privileges || !privileges.editable) {
|
||||
return next(new Error('no privileges'));
|
||||
return next(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ var db = require('./database'),
|
||||
toPid = data.toPid;
|
||||
|
||||
if (uid === null) {
|
||||
return callback(new Error('invalid-user'));
|
||||
return callback(new Error('[[error:invalid-uid]]'));
|
||||
}
|
||||
|
||||
var timestamp = Date.now(),
|
||||
@@ -420,7 +420,7 @@ var db = require('./database'),
|
||||
|
||||
topics.getTopicField(tid, 'cid', function(err, cid) {
|
||||
if(err || !cid) {
|
||||
return callback(err || new Error('invalid-category-id'));
|
||||
return callback(err || new Error('[[error:invalid-cid]]'));
|
||||
}
|
||||
callback(null, cid);
|
||||
});
|
||||
@@ -458,7 +458,7 @@ var db = require('./database'),
|
||||
|
||||
Posts.getPidPage = function(pid, uid, callback) {
|
||||
if(!pid) {
|
||||
return callback(new Error('invalid-pid'));
|
||||
return callback(new Error('[[error:invalid-pid]]'));
|
||||
}
|
||||
|
||||
var index = 0;
|
||||
|
||||
@@ -63,14 +63,14 @@ function uploadPost(req, res, next) {
|
||||
function uploadThumb(req, res, next) {
|
||||
if (!meta.config.allowTopicsThumbnail) {
|
||||
deleteTempFiles(req.files.files);
|
||||
return callback(new Error('Topic Thumbnails are disabled!'));
|
||||
return callback(new Error('[[error:topic-thumbnails-are-disabled]]'));
|
||||
}
|
||||
|
||||
upload(req, res, function(file, next) {
|
||||
if(file.type.match(/image./)) {
|
||||
uploadImage(file, next);
|
||||
} else {
|
||||
next(new Error('Invalid File'));
|
||||
next(new Error('[[error:invalid-file]]'));
|
||||
}
|
||||
}, next);
|
||||
}
|
||||
@@ -85,7 +85,7 @@ function uploadImage(image, callback) {
|
||||
if (meta.config.allowFileUploads) {
|
||||
uploadFile(image, callback);
|
||||
} else {
|
||||
callback(new Error('Uploads are disabled!'));
|
||||
callback(new Error('[[error:uploads-are-disabled]]'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,15 +97,15 @@ function uploadFile(file, callback) {
|
||||
} else {
|
||||
|
||||
if(!meta.config.allowFileUploads) {
|
||||
return callback(new Error('File uploads are not allowed'));
|
||||
return callback(new Error('[[error:uploads-are-disabled]]'));
|
||||
}
|
||||
|
||||
if(!file) {
|
||||
return callback(new Error('invalid file'));
|
||||
return callback(new Error('[[error:invalid-file]]'));
|
||||
}
|
||||
|
||||
if(file.size > parseInt(meta.config.maximumFileSize, 10) * 1024) {
|
||||
return callback(new Error('File too big'));
|
||||
return callback(new Error('[[error:file-too-big, ' + meta.config.maximumFileSize + ']]'));
|
||||
}
|
||||
|
||||
var filename = 'upload-' + utils.generateUUID() + path.extname(file.name);
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
|
||||
Auth.login = function(username, password, next) {
|
||||
if (!username || !password) {
|
||||
return next(new Error('invalid-user'));
|
||||
return next(new Error('[[error:invalid-user-data]]'));
|
||||
}
|
||||
|
||||
var userslug = utils.slugify(username);
|
||||
@@ -170,7 +170,7 @@
|
||||
|
||||
if(!uid) {
|
||||
// Even if a user doesn't exist, compare passwords anyway, so we don't immediately return
|
||||
return next(null, false, 'user doesn\'t exist');
|
||||
return next(null, false, '[[error:no-user]]');
|
||||
}
|
||||
|
||||
user.getUserFields(uid, ['password', 'banned'], function(err, userData) {
|
||||
@@ -179,11 +179,11 @@
|
||||
}
|
||||
|
||||
if (!userData || !userData.password) {
|
||||
return next(new Error('invalid userdata or password'));
|
||||
return next(new Error('[[error:invalid-user-data]]'));
|
||||
}
|
||||
|
||||
if (userData.banned && parseInt(userData.banned, 10) === 1) {
|
||||
return next(null, false, 'User banned');
|
||||
return next(null, false, '[[error:user-banned]]');
|
||||
}
|
||||
|
||||
bcrypt.compare(password, userData.password, function(err, res) {
|
||||
@@ -192,12 +192,12 @@
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
return next(null, false, 'invalid-password');
|
||||
return next(null, false, '[[error:invalid-password]]');
|
||||
}
|
||||
|
||||
next(null, {
|
||||
uid: uid
|
||||
}, 'Authentication successful');
|
||||
}, '[[success:authentication-successful]]');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -69,9 +69,9 @@ var winston = require('winston'),
|
||||
}
|
||||
|
||||
if (parseInt(deleted, 10) && isDelete) {
|
||||
return callback(new Error('topic-already-deleted'));
|
||||
return callback(new Error('[[error:topic-already-deleted]]'));
|
||||
} else if (!parseInt(deleted, 10) && !isDelete) {
|
||||
return callback(new Error('topic-already-restored'));
|
||||
return callback(new Error('[[error:topic-already-restored]]'));
|
||||
}
|
||||
|
||||
topics[isDelete ? 'delete' : 'restore'](tid, function(err) {
|
||||
|
||||
@@ -58,7 +58,7 @@ var async = require('async'),
|
||||
Topics.getTopicDataWithUser = function(tid, callback) {
|
||||
Topics.getTopicData(tid, function(err, topic) {
|
||||
if (err || !topic) {
|
||||
return callback(err || new Error('topic doesn\'t exist'));
|
||||
return callback(err || new Error('[[error:no-topic]]'));
|
||||
}
|
||||
|
||||
user.getUserFields(topic.uid, ['username', 'userslug', 'picture'] , function(err, userData) {
|
||||
@@ -101,7 +101,7 @@ var async = require('async'),
|
||||
|
||||
Topics.getTidPage = function(tid, uid, callback) {
|
||||
if(!tid) {
|
||||
return callback(new Error('invalid-tid'));
|
||||
return callback(new Error('[[error:invalid-tid]]'));
|
||||
}
|
||||
|
||||
async.parallel({
|
||||
@@ -270,7 +270,7 @@ var async = require('async'),
|
||||
Topics.getTopicWithPosts = function(tid, uid, start, end, callback) {
|
||||
Topics.getTopicData(tid, function(err, topicData) {
|
||||
if (err || !topicData) {
|
||||
return callback(err || new Error('Topic tid \'' + tid + '\' not found'));
|
||||
return callback(err || new Error('[[error:no-topic]]'));
|
||||
}
|
||||
|
||||
async.parallel({
|
||||
@@ -328,8 +328,8 @@ var async = require('async'),
|
||||
posts.getPostFields(pid, ['pid', 'uid', 'timestamp'], function(err, postData) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
} else if(!postData) {
|
||||
return callback(new Error('no-teaser-found'));
|
||||
} else if(!postData || !postData.uid) {
|
||||
return callback(new Error('[[error:no-teaser]]'));
|
||||
}
|
||||
|
||||
user.getUserFields(postData.uid, ['username', 'userslug', 'picture'], function(err, userData) {
|
||||
|
||||
@@ -19,11 +19,11 @@ module.exports = function(Topics) {
|
||||
}
|
||||
|
||||
if(!title) {
|
||||
return callback(new Error('invalid-title'));
|
||||
return callback(new Error('[[error:invalid-title]]'));
|
||||
}
|
||||
|
||||
if(!pids || !pids.length) {
|
||||
return callback(new Error('invalid-pids'));
|
||||
return callback(new Error('[[error:invalid-pid]]'));
|
||||
}
|
||||
|
||||
pids.sort();
|
||||
@@ -71,7 +71,7 @@ module.exports = function(Topics) {
|
||||
Topics.movePostToTopic = function(pid, tid, callback) {
|
||||
threadTools.exists(tid, function(err, exists) {
|
||||
if(err || !exists) {
|
||||
return callback(err || new Error('Topic doesn\'t exist'));
|
||||
return callback(err || new Error('[[error:no-topic]]'));
|
||||
}
|
||||
|
||||
posts.getPostFields(pid, ['deleted', 'tid', 'timestamp'], function(err, postData) {
|
||||
@@ -79,8 +79,8 @@ module.exports = function(Topics) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if(!postData) {
|
||||
return callback(new Error('Post doesn\'t exist'));
|
||||
if(!postData || !postData.tid) {
|
||||
return callback(new Error('[[error:no-post]]'));
|
||||
}
|
||||
|
||||
Topics.removePostFromTopic(postData.tid, pid, function(err) {
|
||||
|
||||
@@ -126,11 +126,11 @@ var bcrypt = require('bcryptjs'),
|
||||
}
|
||||
|
||||
if (parseInt(results.banned, 10) === 1) {
|
||||
return callback(new Error('user-banned'));
|
||||
return callback(new Error('[[error:user-banned]]'));
|
||||
}
|
||||
|
||||
if (!results.exists) {
|
||||
return callback(new Error('invalid-user'));
|
||||
return callback(new Error('[[error:no-user]]'));
|
||||
}
|
||||
|
||||
var lastposttime = results.lastposttime;
|
||||
|
||||
@@ -25,17 +25,17 @@ module.exports = function(User) {
|
||||
async.parallel([
|
||||
function(next) {
|
||||
if (userData.email) {
|
||||
next(!utils.isEmailValid(userData.email) ? new Error('Invalid Email!') : null);
|
||||
next(!utils.isEmailValid(userData.email) ? new Error('[[error:invalid-email]]') : null);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
next((!utils.isUserNameValid(userData.username) || !userData.userslug) ? new Error('Invalid Username!') : null);
|
||||
next((!utils.isUserNameValid(userData.username) || !userData.userslug) ? new Error('[[error:invalid-username]]') : null);
|
||||
},
|
||||
function(next) {
|
||||
if (userData.password) {
|
||||
next(!utils.isPasswordValid(userData.password) ? new Error('Invalid Password!') : null);
|
||||
next(!utils.isPasswordValid(userData.password) ? new Error('[[error:invalid-password]]') : null);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
@@ -45,7 +45,7 @@ module.exports = function(User) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
next(exists ? new Error('Username taken!') : null);
|
||||
next(exists ? new Error('[[error:username-taken]]') : null);
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
@@ -54,7 +54,7 @@ module.exports = function(User) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
next(!available ? new Error('Email taken!') : null);
|
||||
next(!available ? new Error('[[error:email-taken]]') : null);
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
|
||||
@@ -18,7 +18,7 @@ module.exports = function(User) {
|
||||
|
||||
function isSignatureValid(next) {
|
||||
if (data.signature !== undefined && data.signature.length > meta.config.maximumSignatureLength) {
|
||||
next(new Error('Signature can\'t be longer than ' + meta.config.maximumSignatureLength + ' characters!'));
|
||||
next(new Error('[[error:signature-too-long, ' + meta.config.maximumSignatureLength + ']]'));
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
@@ -39,7 +39,7 @@ module.exports = function(User) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
next(!available ? new Error('Email not available!') : null);
|
||||
next(!available ? new Error('[[error:email-taken]]') : null);
|
||||
|
||||
});
|
||||
});
|
||||
@@ -55,7 +55,7 @@ module.exports = function(User) {
|
||||
}
|
||||
|
||||
if(!utils.isUserNameValid(data.username) || !userslug) {
|
||||
return next(new Error('Invalid Username!'));
|
||||
return next(new Error('[[error:invalid-username]]'));
|
||||
}
|
||||
|
||||
User.exists(userslug, function(err, exists) {
|
||||
@@ -63,7 +63,7 @@ module.exports = function(User) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
next(exists ? new Error('Username not available!') : null);
|
||||
next(exists ? new Error('[[error:username-taken]]') : null);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -196,7 +196,7 @@ module.exports = function(User) {
|
||||
|
||||
User.changePassword = function(uid, data, callback) {
|
||||
if(!data || !data.uid) {
|
||||
return callback(new Error('invalid-uid'));
|
||||
return callback(new Error('[[error:invalid-uid]]'));
|
||||
}
|
||||
|
||||
function hashAndSetPassword(callback) {
|
||||
|
||||
@@ -40,7 +40,7 @@ var async = require('async'),
|
||||
UserReset.send = function(socket, email, callback) {
|
||||
user.getUidByEmail(email, function(err, uid) {
|
||||
if(err || !uid) {
|
||||
return callback(err || new Error('invalid-email'));
|
||||
return callback(err || new Error('[[error:invalid-email]]'));
|
||||
}
|
||||
|
||||
// Generate a new reset code
|
||||
|
||||
@@ -37,7 +37,7 @@ module.exports = function(User) {
|
||||
User.saveSettings = function(uid, data, callback) {
|
||||
|
||||
if(!data.topicsPerPage || !data.postsPerPage || parseInt(data.topicsPerPage, 10) <= 0 || parseInt(data.postsPerPage, 10) <= 0) {
|
||||
return callback(new Error('Invalid pagination value!'));
|
||||
return callback(new Error('[[error:invalid-pagination-value]]'));
|
||||
}
|
||||
|
||||
plugins.fireHook('action:user.saveSettings', {uid: uid, settings: data});
|
||||
|
||||
Reference in New Issue
Block a user