-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilter.js
More file actions
29 lines (28 loc) · 1.03 KB
/
filter.js
File metadata and controls
29 lines (28 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var schema = require('./schema/exports.js'),
helper = require('./public/utils/helper.js');
var filter = {
keyFilter: function (req, res, next){
if(!req.query || !req.query.appKey)
return res.json(helper.genarateResponse(400, null, null, "Please Provide AppKey"));
else{
if(req.query.appKey == global._APPKEY)
next();
else{
global._LOGGER.error('Invalid AppKey : ' + req.query.appKey);
return res.json(helper.genarateResponse(400, null, null, "Invalid AppKey"));
}
}
},
userFilter: function(req, res, next){
if(!req.query || !req.query.user_id)
return res.json(helper.genarateResponse(400, null, null, "user_id required"));
schema.userModel.findById(req.query.user_id, function (err, docs) {
if (err || !docs){
global._LOGGER.error('Invalid user_id : ' + req.query.user_id);
return res.json(helper.genarateResponse(400, null, null, "Invalid user_id"));
}
next();
});
}
}
module.exports = filter;