diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-12 06:06:41 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-12 06:06:41 +0100 |
| commit | b29bf8bdc1d43699160d542a636fb1e65362b7ae (patch) | |
| tree | c298274a5cfc2dbe715b4b1572896fc0adc36131 /bucky | |
| parent | 5dadac51b65c714e2235f28c000a646716e2a63a (diff) | |
bump last seen
Diffstat (limited to 'bucky')
| -rw-r--r-- | bucky/app/bucky.js | 5 | ||||
| -rw-r--r-- | bucky/app/router.js | 10 | ||||
| -rw-r--r-- | bucky/util/auth.js | 2 |
3 files changed, 13 insertions, 4 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index 41c3bff..a31d50f 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -170,6 +170,7 @@ var bucky = module.exports = { next() }) }, + bumpViewCount: function(req, res, next) { res.thread.set('viewed', res.thread.get('viewed') + 1) res.thread.save().then( () => next() ) @@ -393,6 +394,10 @@ var bucky = module.exports = { } }) }, + bumpLastSeen: function(req, res, next) { + req.user.set('lastseen', util.now()) + req.user.save().then( () => next() ) + }, /* PRIVACY */ checkThreadPrivacy: function(req, res, next) { diff --git a/bucky/app/router.js b/bucky/app/router.js index 2e690fb..21abe97 100644 --- a/bucky/app/router.js +++ b/bucky/app/router.js @@ -12,9 +12,11 @@ module.exports = function(app){ auth.init() - app.get("/", middleware.ensureAuthenticated, function(req, res){ - res.redirect('/index') - }) + app.get("/", + middleware.ensureAuthenticated, + function(req, res){ + res.redirect('/index') + }) app.get("/index", middleware.ensureAuthenticated, function(req, res){ res.render("pages/index", { title: fortune("titles"), @@ -71,6 +73,7 @@ module.exports = function(app){ bucky.ensureFileCountsForThreads, bucky.ensureKeywordsForThreads, bucky.ensureHootbox, + bucky.bumpLastSeen, function(req, res){ res.json({ threads: res.threads, @@ -110,6 +113,7 @@ module.exports = function(app){ bucky.ensureCommentsForThread, bucky.ensureFilesForThread, bucky.prepareThread, + bucky.bumpLastSeen, function(req, res){ res.json({ thread: res.thread, diff --git a/bucky/util/auth.js b/bucky/util/auth.js index dd3df6f..97e25b4 100644 --- a/bucky/util/auth.js +++ b/bucky/util/auth.js @@ -56,6 +56,7 @@ var auth = module.exports = { } db.createUser(data).then(() => next()) }, + passport.authenticate("local"), function (req, res, next) { var username = req.user.get('username') Promise.all([ @@ -79,7 +80,6 @@ var auth = module.exports = { }), ]).then(() => next()) }, - passport.authenticate("local"), auth.login) app.put("/api/login", passport.authenticate("local"), |
