mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
16 lines
358 B
JavaScript
16 lines
358 B
JavaScript
|
const constants = require('../../../lib/constants');
|
||
|
|
||
|
module.exports = function updateUserLastSeenMiddleware(req, res, next) {
|
||
|
if (!req.user) {
|
||
|
return next();
|
||
|
}
|
||
|
|
||
|
if (Date.now() - req.user.get('last_seen') < constants.ONE_HOUR_MS) {
|
||
|
return next();
|
||
|
}
|
||
|
|
||
|
req.user.updateLastSeen().then(() => {
|
||
|
next();
|
||
|
}, next);
|
||
|
};
|