From a24b8bc8f59de2d0a84a44c16fd491994826f39d Mon Sep 17 00:00:00 2001 From: HF Date: Thu, 22 Sep 2022 00:55:13 +0200 Subject: [PATCH] test things remove captcha requirement from chat --- src/components/Captcha.jsx | 3 ++- src/components/GlobalCaptcha.jsx | 14 ++++++++++++-- src/core/ChatProvider.js | 2 -- src/data/redis/chat.js | 5 +---- src/data/redis/client.js | 2 +- src/data/redis/lua/allowedChat.lua | 7 ------- src/routes/api/banme.js | 30 ++++++++++++++++++++++++++++++ src/routes/api/index.js | 3 +++ src/store/actions/fetch.js | 6 ++++++ 9 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 src/routes/api/banme.js diff --git a/src/components/Captcha.jsx b/src/components/Captcha.jsx index 54d4fea..dfd5337 100644 --- a/src/components/Captcha.jsx +++ b/src/components/Captcha.jsx @@ -37,7 +37,7 @@ const floatStyle = { * autoload: Load captcha immediately and autofocus input textbox * width: width of the captcha image */ -const Captcha = ({ autoload, width }) => { +const Captcha = ({ autoload, width, setLegit }) => { const [captchaData, setCaptchaData] = useState({}); const [errors, setErrors] = useState([]); const [imgLoaded, setImgLoaded] = useState(false); @@ -141,6 +141,7 @@ const Captcha = ({ autoload, width }) => { autoCorrect="off" autoCapitalize="off" spellCheck="false" + onChange={() => setLegit && setLegit(true)} autoFocus={autoload} style={{ width: '6em', diff --git a/src/components/GlobalCaptcha.jsx b/src/components/GlobalCaptcha.jsx index e8a722f..74bf6ba 100644 --- a/src/components/GlobalCaptcha.jsx +++ b/src/components/GlobalCaptcha.jsx @@ -8,10 +8,14 @@ import React, { useState } from 'react'; import { t } from 'ttag'; import Captcha from './Captcha'; -import { requestSolveCaptcha } from '../store/actions/fetch'; +import { + requestSolveCaptcha, + requestBanMe, +} from '../store/actions/fetch'; const GlobalCaptcha = ({ close }) => { const [errors, setErrors] = useState([]); + const [legit, setLegit] = useState(false); // used to be able to force Captcha rerender on error const [captKey, setCaptKey] = useState(Date.now()); @@ -19,6 +23,12 @@ const GlobalCaptcha = ({ close }) => {
{ e.preventDefault(); + // ---- + const test = document.getElementById('void-bot'); + if (!legit || test) { + await requestBanMe((legit) ? 1 : 2); + } + // ---- const text = e.target.captcha.value; const captchaid = e.target.captchaid.value; const { errors: resErrors } = await requestSolveCaptcha( @@ -38,7 +48,7 @@ const GlobalCaptcha = ({ close }) => { {t`Error`}: {error}

))} - +