diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-08-07 18:36:25 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-08-07 18:36:25 -0400 |
| commit | 18e8ca03b90f124968400ccc742744c3ed01547a (patch) | |
| tree | 7ed7f7292e36f96aa5af7d83dd38ab7bc776149d /server/lib/middleware.js | |
| parent | e0aebb7ef327f29c0ab8f5b75a24c5d823dfd90f (diff) | |
cleanup
Diffstat (limited to 'server/lib/middleware.js')
| -rw-r--r-- | server/lib/middleware.js | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/server/lib/middleware.js b/server/lib/middleware.js index fe4dc49..94c4acd 100644 --- a/server/lib/middleware.js +++ b/server/lib/middleware.js @@ -68,22 +68,8 @@ var middleware = { ensureUserProjectsCount: function(req, res, next){ var counts = { stock: 0, basic: 0, pro: 0 } res.locals.projectCounts = counts - Project.count({ user_id: req.user.id, layout_type: 0 }, function(err, count){ - res.locals.projectCounts.stock = count || 0 - if (req.user.plan_level > 0) { return middleware.ensureBasicProjectsCount(req, res, next) } - else next() - }) - }, - ensureBasicProjectsCount: function(req, res, next){ - Project.count({ user_id: req.user.id, layout_type: 1 }, function(err, count){ - res.locals.projectCounts.basic = count || 0 - if (req.user.plan_level > 1) { return middleware.ensureProProjectsCount(req, res, next) } - else next() - }) - }, - ensureProProjectsCount: function(req, res, next){ - Project.count({ user_id: req.user.id, layout_type: 2 }, function(err, count){ - res.locals.projectCounts.pro = count || 0 + Project.count({ user_id: req.user._id }, function(err, count){ + res.locals.projectCount = count || 0 next() }) }, @@ -93,15 +79,8 @@ var middleware = { res.locals.layoutCounts = counts if (req.user.plan_level == 0) { return next() } - Layout.count({ user_id: req.user.id, layout_type: 1 }, function(err, count){ - res.locals.layoutCounts.basic = count || 0 - if (req.user.plan_level > 1) { return middleware.ensureProLayoutsCount(req, res, next) } - else next() - }) - }, - ensureProLayoutsCount: function(req, res, next){ - Project.count({ user_id: req.user.id, layout_type: 2 }, function(err, count){ - res.locals.layoutCounts.pro = count || 0 + Layout.count({ user_id: req.user._id }, function(err, count){ + res.locals.layoutCount = count || 0 next() }) }, |
