From f185e13175313f883a682ec9d2d1de77e296ba62 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 1 Apr 2014 12:01:11 -0400 Subject: [PATCH 1/2] added check to isReadyToPost, banned and exists --- src/user.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/user.js b/src/user.js index 687a67a4b6..1f0f1be6ab 100644 --- a/src/user.js +++ b/src/user.js @@ -110,12 +110,30 @@ var bcrypt = require('bcryptjs'), }; User.isReadyToPost = function(uid, callback) { - User.getUserField(uid, 'lastposttime', function(err, lastposttime) { - if(err) { + async.parallel({ + banned: function(next) { + User.getUserField(uid, 'banned',next); + }, + exists: function(next) { + db.exists('user:' + uid, next); + }, + lastposttime: function(next) { + User.getUserField(uid, 'lastposttime', next); + } + }, function(err, results) { + if (err) { return callback(err); } +console.log(results); + if (parseInt(results.banned, 10) === 1) { + return callback(new Error('user-banned')); + } - if(!lastposttime) { + if (!results.exists) { + return callback(new Error('user-deleted')); + } + var lastposttime = results.lastposttime; + if (!lastposttime) { lastposttime = 0; } From 99e6223bf03401296d3e370613df9347dc57584b Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 1 Apr 2014 12:02:05 -0400 Subject: [PATCH 2/2] removed console.log --- src/user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/user.js b/src/user.js index 1f0f1be6ab..30305bb8e8 100644 --- a/src/user.js +++ b/src/user.js @@ -124,7 +124,7 @@ var bcrypt = require('bcryptjs'), if (err) { return callback(err); } -console.log(results); + if (parseInt(results.banned, 10) === 1) { return callback(new Error('user-banned')); }