Skip to content

Node.js based forum software built for the modern web

fixes #5226

Julian Lamcafbdfd83e0b
diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js
index 1d45b2cbd5..4612226d59 100644
--- a/src/controllers/authentication.js
+++ b/src/controllers/authentication.js
@@ -387,7 +387,11 @@ authenticationController.localLogin = function (req, username, password, next) {
// Retrieve ban reason and show error
return user.getLatestBanInfo(uid, function (err, banInfo) {
if (err) {
- next(err);
+ if (err.message === 'no-ban-info') {
+ next(new Error('[[error:user-banned]]'));
+ } else {
+ next(err);
+ }
} else if (banInfo.reason) {
next(new Error('[[error:user-banned-reason, ' + banInfo.reason + ']]'));
} else {
diff --git a/src/user/info.js b/src/user/info.js
index 1ed9cdef14..296dd9a723 100644
--- a/src/user/info.js
+++ b/src/user/info.js
@@ -16,6 +16,10 @@ module.exports = function (User) {
async.waterfall([
async.apply(db.getSortedSetRevRangeWithScores, 'uid:' + uid + ':bans', 0, 0),
function (record, next) {
+ if (!record.length) {
+ return next(new Error('no-ban-info'));
+ }
+
timestamp = record[0].score;
expiry = record[0].value;