middleware.updateLastOnlineTime; middleware.prepareAPI (reinstated)

v1.18.x
psychobunny 11 years ago
parent f943a194b6
commit 209bcaba8c

@ -13,6 +13,7 @@ var app,
meta = require('./../meta'),
translator = require('./../../public/src/translator'),
user = require('./../user'),
db = require('./../database'),
controllers = {
api: require('./../controllers/api')
@ -30,6 +31,21 @@ middleware.authenticate = function(req, res, next) {
}
};
middleware.updateLastOnlineTime = function(req, res, next) {
if(req.user) {
user.updateLastOnlineTime(req.user.uid);
}
db.sortedSetAdd('ip:recent', Date.now(), req.ip || 'Unknown');
next();
};
middleware.prepareAPI = function(req, res, next) {
res.locals.isAPI = true;
next();
};
middleware.checkGlobalPrivacySettings = function(req, res, next) {
var callerUID = req.user ? parseInt(req.user.uid, 10) : 0;

@ -17,16 +17,7 @@ var path = require('path'),
module.exports = function(app, middleware, controllers) {
app.namespace('/api', function () {
app.all('*', function(req, res, next) {
if(req.user) {
user.updateLastOnlineTime(req.user.uid);
}
db.sortedSetAdd('ip:recent', Date.now(), req.ip || 'Unknown');
res.locals.isAPI = true;
next();
});
app.all('*', middleware.updateLastOnlineTime, middleware.prepareAPI);
app.get('/user/uid/:uid', middleware.checkGlobalPrivacySettings, controllers.accounts.getUserByUID);

Loading…
Cancel
Save