diff --git a/src/user/bans.js b/src/user/bans.js index 1795fc64e9..ad51c7c07c 100644 --- a/src/user/bans.js +++ b/src/user/bans.js @@ -84,13 +84,13 @@ module.exports = function (User) { }; User.getBannedReason = function (uid, callback) { - // Grabs the latest ban reason - db.getSortedSetRevRange('banned:' + uid + ':reasons', 0, 0, function (err, reasons) { - if (err) { - return callback(err); - } - - callback(null, reasons.length ? reasons[0] : ''); - }); + async.waterfall([ + function (next) { + db.getSortedSetRevRange('banned:' + uid + ':reasons', 0, 0, next); + }, + function (reasons, next) { + next(null, reasons.length ? reasons[0] : ''); + }, + ], callback); }; }; diff --git a/test/user.js b/test/user.js index 9eae6f7f09..87bcf39e70 100644 --- a/test/user.js +++ b/test/user.js @@ -827,6 +827,13 @@ describe('User', function () { }); }); }); + + it('should error if until is NaN', function (done) { + User.ban(testUid, 'asd', function (err) { + assert.equal(err.message, '[[error:ban-expiry-missing]]'); + done(); + }); + }); }); describe('digests', function () {