mirror of https://gitgud.io/fatchan/jschan.git
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.0 KiB
29 lines
1.0 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.upsertedId || bypass.insertedId || existingBypassId;
|
|
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.',
|
|
});
|
|
|
|
};
|
|
|