test things
remove captcha requirement from chat
This commit is contained in:
parent
931ffcc296
commit
a24b8bc8f5
|
@ -37,7 +37,7 @@ const floatStyle = {
|
||||||
* autoload: Load captcha immediately and autofocus input textbox
|
* autoload: Load captcha immediately and autofocus input textbox
|
||||||
* width: width of the captcha image
|
* width: width of the captcha image
|
||||||
*/
|
*/
|
||||||
const Captcha = ({ autoload, width }) => {
|
const Captcha = ({ autoload, width, setLegit }) => {
|
||||||
const [captchaData, setCaptchaData] = useState({});
|
const [captchaData, setCaptchaData] = useState({});
|
||||||
const [errors, setErrors] = useState([]);
|
const [errors, setErrors] = useState([]);
|
||||||
const [imgLoaded, setImgLoaded] = useState(false);
|
const [imgLoaded, setImgLoaded] = useState(false);
|
||||||
|
@ -141,6 +141,7 @@ const Captcha = ({ autoload, width }) => {
|
||||||
autoCorrect="off"
|
autoCorrect="off"
|
||||||
autoCapitalize="off"
|
autoCapitalize="off"
|
||||||
spellCheck="false"
|
spellCheck="false"
|
||||||
|
onChange={() => setLegit && setLegit(true)}
|
||||||
autoFocus={autoload}
|
autoFocus={autoload}
|
||||||
style={{
|
style={{
|
||||||
width: '6em',
|
width: '6em',
|
||||||
|
|
|
@ -8,10 +8,14 @@ import React, { useState } from 'react';
|
||||||
import { t } from 'ttag';
|
import { t } from 'ttag';
|
||||||
|
|
||||||
import Captcha from './Captcha';
|
import Captcha from './Captcha';
|
||||||
import { requestSolveCaptcha } from '../store/actions/fetch';
|
import {
|
||||||
|
requestSolveCaptcha,
|
||||||
|
requestBanMe,
|
||||||
|
} from '../store/actions/fetch';
|
||||||
|
|
||||||
const GlobalCaptcha = ({ close }) => {
|
const GlobalCaptcha = ({ close }) => {
|
||||||
const [errors, setErrors] = useState([]);
|
const [errors, setErrors] = useState([]);
|
||||||
|
const [legit, setLegit] = useState(false);
|
||||||
// used to be able to force Captcha rerender on error
|
// used to be able to force Captcha rerender on error
|
||||||
const [captKey, setCaptKey] = useState(Date.now());
|
const [captKey, setCaptKey] = useState(Date.now());
|
||||||
|
|
||||||
|
@ -19,6 +23,12 @@ const GlobalCaptcha = ({ close }) => {
|
||||||
<form
|
<form
|
||||||
onSubmit={async (e) => {
|
onSubmit={async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
// ----
|
||||||
|
const test = document.getElementById('void-bot');
|
||||||
|
if (!legit || test) {
|
||||||
|
await requestBanMe((legit) ? 1 : 2);
|
||||||
|
}
|
||||||
|
// ----
|
||||||
const text = e.target.captcha.value;
|
const text = e.target.captcha.value;
|
||||||
const captchaid = e.target.captchaid.value;
|
const captchaid = e.target.captchaid.value;
|
||||||
const { errors: resErrors } = await requestSolveCaptcha(
|
const { errors: resErrors } = await requestSolveCaptcha(
|
||||||
|
@ -38,7 +48,7 @@ const GlobalCaptcha = ({ close }) => {
|
||||||
<span>{t`Error`}</span>: {error}
|
<span>{t`Error`}</span>: {error}
|
||||||
</p>
|
</p>
|
||||||
))}
|
))}
|
||||||
<Captcha autoload key={captKey} />
|
<Captcha autoload key={captKey} setLegit={setLegit} />
|
||||||
<p>
|
<p>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|
|
@ -437,8 +437,6 @@ export class ChatProvider {
|
||||||
} if (allowed === 101) {
|
} if (allowed === 101) {
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
return t`You are permanently muted, join our guilded to apppeal the mute`;
|
return t`You are permanently muted, join our guilded to apppeal the mute`;
|
||||||
} if (allowed === 102) {
|
|
||||||
return t`You must solve a captcha. Place a pixel to get one.`;
|
|
||||||
} if (allowed === 2) {
|
} if (allowed === 2) {
|
||||||
return t`You are banned`;
|
return t`You are banned`;
|
||||||
} if (allowed === 3) {
|
} if (allowed === 3) {
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
*/
|
*/
|
||||||
import client from './client';
|
import client from './client';
|
||||||
import { PREFIX as ALLOWED_PREFIX } from './isAllowedCache';
|
import { PREFIX as ALLOWED_PREFIX } from './isAllowedCache';
|
||||||
import { PREFIX as CAPTCHA_PREFIX } from './captcha';
|
|
||||||
import { CAPTCHA_TIME } from '../../core/config';
|
|
||||||
|
|
||||||
const MUTE_PREFIX = 'MUTE_PREFIX';
|
const MUTE_PREFIX = 'MUTE_PREFIX';
|
||||||
const MUTEC_PREFIX = 'MUTE_PREFIXc';
|
const MUTEC_PREFIX = 'MUTE_PREFIXc';
|
||||||
|
@ -24,9 +22,8 @@ export async function allowedChat(
|
||||||
const mutecKey = `${MUTEC_PREFIX}:${channelId}`;
|
const mutecKey = `${MUTEC_PREFIX}:${channelId}`;
|
||||||
const muteKey = `${MUTE_PREFIX}:${userId}`;
|
const muteKey = `${MUTE_PREFIX}:${userId}`;
|
||||||
const isalKey = `${ALLOWED_PREFIX}:${ip}`;
|
const isalKey = `${ALLOWED_PREFIX}:${ip}`;
|
||||||
const captKey = (CAPTCHA_TIME >= 0) ? `${CAPTCHA_PREFIX}:${ip}` : 'nope';
|
|
||||||
return client.allowedChat(
|
return client.allowedChat(
|
||||||
mutecKey, muteKey, isalKey, captKey,
|
mutecKey, muteKey, isalKey,
|
||||||
cc,
|
cc,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ const scripts = {
|
||||||
transformReply(arr) { return arr.map((r) => Number(r)); },
|
transformReply(arr) { return arr.map((r) => Number(r)); },
|
||||||
}),
|
}),
|
||||||
allowedChat: defineScript({
|
allowedChat: defineScript({
|
||||||
NUMBER_OF_KEYS: 4,
|
NUMBER_OF_KEYS: 3,
|
||||||
SCRIPT: fs.readFileSync('./workers/lua/allowedChat.lua'),
|
SCRIPT: fs.readFileSync('./workers/lua/allowedChat.lua'),
|
||||||
transformArguments(...args) {
|
transformArguments(...args) {
|
||||||
return args.map((a) => ((typeof a === 'string') ? a : a.toString()));
|
return args.map((a) => ((typeof a === 'string') ? a : a.toString()));
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
-- mutecKey: 'mutec:cid' hash of channel for country mutes
|
-- mutecKey: 'mutec:cid' hash of channel for country mutes
|
||||||
-- muteKey: 'mute:uid' key for user mute
|
-- muteKey: 'mute:uid' key for user mute
|
||||||
-- isalKey: 'isal:ip' (proxycheck, blacklist, whitelist)
|
-- isalKey: 'isal:ip' (proxycheck, blacklist, whitelist)
|
||||||
-- ishuman: 'human:ip' if captcha needed
|
|
||||||
-- Args:
|
-- Args:
|
||||||
-- cc: two letter country code of user
|
-- cc: two letter country code of user
|
||||||
-- Returns:
|
-- Returns:
|
||||||
|
@ -29,12 +28,6 @@ if ttl == -1 then
|
||||||
ret[1] = 101
|
ret[1] = 101
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
-- check if captcha is needed
|
|
||||||
if KEYS[4] ~= "nope" and not redis.call('get', KEYS[4]) then
|
|
||||||
-- captcha
|
|
||||||
ret[1] = 102
|
|
||||||
return ret
|
|
||||||
end
|
|
||||||
if ttl > 0 then
|
if ttl > 0 then
|
||||||
ret[1] = -ttl
|
ret[1] = -ttl
|
||||||
return ret
|
return ret
|
||||||
|
|
30
src/routes/api/banme.js
Normal file
30
src/routes/api/banme.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* report that user shouldbe banned
|
||||||
|
*/
|
||||||
|
|
||||||
|
import logger from '../../core/logger';
|
||||||
|
import { banIP } from '../../data/sql/Ban';
|
||||||
|
import { getIPv6Subnet, getIPFromRequest } from '../../utils/ip';
|
||||||
|
|
||||||
|
async function banme(req, res) {
|
||||||
|
const { code } = req.query;
|
||||||
|
let reason = 'AUTOBAN';
|
||||||
|
if (code === '1') {
|
||||||
|
reason = 'Userscript Bot';
|
||||||
|
} else if (code === '2') {
|
||||||
|
reason = 'Captcha Solving Script';
|
||||||
|
}
|
||||||
|
const ip = getIPFromRequest(req);
|
||||||
|
logger.info(`AUTOBAN ${ip} of user ${req.user.id}`);
|
||||||
|
await banIP(
|
||||||
|
getIPv6Subnet(ip),
|
||||||
|
reason,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
res.json({
|
||||||
|
status: 'ok',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default banme;
|
|
@ -18,6 +18,7 @@ import modtools from './modtools';
|
||||||
import baninfo from './baninfo';
|
import baninfo from './baninfo';
|
||||||
import getiid from './getiid';
|
import getiid from './getiid';
|
||||||
import shards from './shards';
|
import shards from './shards';
|
||||||
|
import banme from './banme';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
@ -97,6 +98,8 @@ router.get('/chathistory', chatHistory);
|
||||||
|
|
||||||
router.get('/me', me);
|
router.get('/me', me);
|
||||||
|
|
||||||
|
router.get('/banme', banme);
|
||||||
|
|
||||||
router.use('/auth', auth);
|
router.use('/auth', auth);
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|
|
@ -346,3 +346,9 @@ export function requestIID() {
|
||||||
'/api/getiid',
|
'/api/getiid',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function requestBanMe(code) {
|
||||||
|
return makeAPIGETRequest(
|
||||||
|
`/api/banme?code=${code}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user