updated logging
This commit is contained in:
parent
67601ea97f
commit
097ef744d7
2 changed files with 18 additions and 12 deletions
|
@ -1,5 +1,3 @@
|
|||
const logger = require('winston');
|
||||
|
||||
const { details: { host }, publishing: { disabled, disabledMessage } } = require('@config/siteConfig');
|
||||
|
||||
const { sendGATimingEvent } = require('../../../../utils/googleAnalytics.js');
|
||||
|
@ -22,12 +20,6 @@ const authenticateUser = require('./authentication.js');
|
|||
*/
|
||||
|
||||
const claimPublish = ({ body, files, headers, ip, originalUrl, user }, res) => {
|
||||
// logging
|
||||
logger.info('PUBLISH REQUEST:', {
|
||||
ip,
|
||||
headers,
|
||||
body,
|
||||
});
|
||||
// check for disabled publishing
|
||||
if (disabled) {
|
||||
return res.status(503).json({
|
||||
|
|
|
@ -1,9 +1,23 @@
|
|||
const logger = require('winston');
|
||||
|
||||
const torCheck = (req, res, next) => { // custom logging middleware to log all incoming http requests
|
||||
const { ip } = req;
|
||||
logger.debug(`tor check for ${ip}`);
|
||||
next();
|
||||
function ipIsInTorList (ip) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const torCheck = ({ ip, headers, body }, res, next) => {
|
||||
logger.debug(`tor check for:`, {
|
||||
ip,
|
||||
headers,
|
||||
body,
|
||||
});
|
||||
// check the tor node list
|
||||
if (ipIsInTorList(ip)) {
|
||||
return res.status('400').json({
|
||||
success: 'false',
|
||||
message: 'Unfortunately this api route is not currently available for tor users. We are working on a solution that will allow tor users to publish in the future.',
|
||||
});
|
||||
};
|
||||
return next();
|
||||
};
|
||||
|
||||
module.exports = torCheck;
|
||||
|
|
Loading…
Add table
Reference in a new issue