jschan - Anonymous imageboard software. Classic look, modern features and feel. Works without JavaScript and supports Tor, I2P, Lokinet, etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

29 lines
1.1 KiB

'use strict';
const { Bypass } = require(__dirname+'/../../db/')
, dynamicResponse = require(__dirname+'/../../lib/misc/dynamic.js')
, config = require(__dirname+'/../../lib/misc/config.js')
, production = process.env.NODE_ENV === 'production';
module.exports = async (req, res) => {
const { secureCookies, blockBypass } = config.get;
const existingBypassId = req.signedCookies.bypassid || res.locals.pseudoIp;
const bypass = await Bypass.getBypass(res.locals.anonymizer, existingBypassId, blockBypass.expireAfterUses);
const bypassId = bypass.insertedId || existingBypassId; // if upserted, insertedId will be null, and will be the existingId
res.locals.blockBypass = true;
res.cookie('bypassid', bypassId.toString(), {
'maxAge': blockBypass.expireAfterTime,
'secure': production && secureCookies && (req.headers['x-forwarded-proto'] === 'https'),
'sameSite': 'strict',
'signed': true,
});
return dynamicResponse(req, res, 200, 'message', {
'minimal': req.body.minimal,
'title': 'Success',
'message': 'Completed block bypass, you may go back and make your post.',
});
};