block bypass assistance for users with SzPD

jschan
Thomas Lynch 2 years ago
parent 816e772484
commit 60cc35b389
Signed by: fatchan
GPG Key ID: 112884AA57DF40B1
  1. 6
      db/bypass.js
  2. 4
      helpers/checks/blockbypass.js
  3. 2
      helpers/checks/torprebypass.js
  4. 2
      models/forms/blockbypass.js

@ -8,10 +8,11 @@ module.exports = {
db,
checkBypass: (id) => {
checkBypass: (id, anonymizer=false) => {
const { blockBypass } = config.get;
return db.findOneAndUpdate({
'_id': id,
'anonymizer': anonymizer,
'uses': {
'$lte': blockBypass.expireAfterUses
}
@ -22,10 +23,11 @@ module.exports = {
}).then(r => r.value);
},
getBypass: () => {
getBypass: (anonymizer=false) => {
const { blockBypass } = config.get;
return db.insertOne({
'uses': 0,
'anonymizer': anonymizer,
'expireAt': new Date(Date.now() + blockBypass.expireAfterTime)
});
},

@ -37,7 +37,7 @@ module.exports = async (req, res, next) => {
if (bypassId && bypassId.length === 24) {
try {
const bypassMongoId = ObjectId(bypassId);
bypass = await Bypass.checkBypass(bypassMongoId);
bypass = await Bypass.checkBypass(bypassMongoId, res.locals.anonymizer);
res.locals.blockBypass = true;
} catch (err) {
return next(err);
@ -53,7 +53,7 @@ module.exports = async (req, res, next) => {
if (res.locals.solvedCaptcha) {
//they dont have a valid bypass, but just solved board captcha, so give them a new one
const newBypass = await Bypass.getBypass();
const newBypass = await Bypass.getBypass(res.locals.anonymizer);
const newBypassId = newBypass.insertedId;
res.locals.blockBypass = true;
res.cookie('bypassid', newBypassId.toString(), {

@ -50,7 +50,7 @@ module.exports = async (req, res, next) => {
&& !blockBypass.forceAnonymizers //AND its not forced for anonymizers
&& !bypassId)) { //AND they dont already have one,
//then give the user a bypass id
const newBypass = await Bypass.getBypass();
const newBypass = await Bypass.getBypass(res.locals.anonymizer);
const newBypassId = newBypass.insertedId;
bypassId = newBypassId.toString();
res.locals.preFetchedBypassId = bypassId;

@ -8,7 +8,7 @@ const { Bypass } = require(__dirname+'/../../db/')
module.exports = async (req, res, next) => {
const { secureCookies, blockBypass } = config.get;
const bypass = await Bypass.getBypass();
const bypass = await Bypass.getBypass(res.locals.anonymizer);
const bypassId = bypass.insertedId;
res.locals.blockBypass = true;

Loading…
Cancel
Save