Skip to content

Node.js based forum software built for the modern web

added lots of error keys

barisusakli1f77df794a87
diff --git a/public/language/en_GB/error.json b/public/language/en_GB/error.json
index c60dfa0692..446bd43368 100644
--- a/public/language/en_GB/error.json
+++ b/public/language/en_GB/error.json
@@ -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!"
}
\ No newline at end of file
diff --git a/public/language/en_GB/success.json b/public/language/en_GB/success.json
index 397b857c38..d38b90c6fa 100644
--- a/public/language/en_GB/success.json
+++ b/public/language/en_GB/success.json
@@ -1,4 +1,5 @@
{
- "topic-post": "You have successfully posted."
+ "topic-post": "You have successfully posted.",
+ "authentication-successful": "Authentication Successful"
}
\ No newline at end of file
diff --git a/src/postTools.js b/src/postTools.js
index 7ecf7387ba..3cb73e2282 100644
--- a/src/postTools.js
+++ b/src/postTools.js
@@ -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();
}
diff --git a/src/posts.js b/src/posts.js
index 08603611ea..0fd976995d 100644
--- a/src/posts.js
+++ b/src/posts.js
@@ -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;
diff --git a/src/routes/api.js b/src/routes/api.js
index 909f142863..54c72e3e45 100644
--- a/src/routes/api.js
+++ b/src/routes/api.js
@@ -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);
diff --git a/src/routes/authentication.js b/src/routes/authentication.js
index a2d9f66e44..2728f58116 100644
--- a/src/routes/authentication.js
+++ b/src/routes/authentication.js
@@ -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]]');
});
});
});
diff --git a/src/threadTools.js b/src/threadTools.js
index 27f2da6fe2..7e7c8e509b 100644
--- a/src/threadTools.js
+++ b/src/threadTools.js
@@ -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) {
diff --git a/src/topics.js b/src/topics.js
index 2da58b7245..a5cbd0b69b 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -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) {
diff --git a/src/topics/fork.js b/src/topics/fork.js
index 6cda238973..005b137058 100644
--- a/src/topics/fork.js
+++ b/src/topics/fork.js
@@ -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) {
diff --git a/src/user.js b/src/user.js
index 93805a567b..a06219b957 100644
--- a/src/user.js
+++ b/src/user.js
@@ -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;
diff --git a/src/user/create.js b/src/user/create.js
index 33d7a5fd8c..f8f95b0878 100644
--- a/src/user/create.js
+++ b/src/user/create.js
@@ -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();
diff --git a/src/user/profile.js b/src/user/profile.js
index 50a33112e5..8620dde36e 100644
--- a/src/user/profile.js
+++ b/src/user/profile.js
@@ -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) {
diff --git a/src/user/reset.js b/src/user/reset.js
index 330f49c843..7e3b2d75c8 100644
--- a/src/user/reset.js
+++ b/src/user/reset.js
@@ -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
diff --git a/src/user/settings.js b/src/user/settings.js
index bc28622960..7e9665d9f0 100644
--- a/src/user/settings.js
+++ b/src/user/settings.js
@@ -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});