From 9b96e390af1c8daafcc9dc41f4873c8640cfbf5a Mon Sep 17 00:00:00 2001 From: HF Date: Thu, 18 Mar 2021 14:41:19 +0100 Subject: [PATCH] enter in text field -> submit captcha --- src/components/Captcha.jsx | 37 +++++++++++++++++++++---------------- src/utils/captcha.js | 2 +- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/components/Captcha.jsx b/src/components/Captcha.jsx index de44164..db5aedd 100644 --- a/src/components/Captcha.jsx +++ b/src/components/Captcha.jsx @@ -23,7 +23,19 @@ const Captcha = ({ callback, close }) => { const [imgLoaded, setImgLoaded] = useState(false); return ( -
+
{ + e.preventDefault(); + const { errors: resErrors } = await requestSolveCaptcha(text); + if (resErrors) { + setCaptchaUrl(getUrl()); + setText(''); + setErrors(resErrors); + } else { + close(); + } + }} + > {errors.map((error) => (

{t`Error`}: {error} @@ -67,7 +79,7 @@ const Captcha = ({ callback, close }) => { tabIndex={-1} title={t`Reload`} className="modallink" - style={{fontSize: 28}} + style={{ fontSize: 28 }} onClick={() => { setImgLoaded(false); setCaptchaUrl(getUrl()); @@ -81,6 +93,9 @@ const Captcha = ({ callback, close }) => { type="text" value={text} autoComplete="off" + autoCorrect="off" + autoCapitalize="off" + spellCheck="false" style={{ width: '6em', fontSize: 21, @@ -97,30 +112,20 @@ const Captcha = ({ callback, close }) => {  

)} - + ); }; diff --git a/src/utils/captcha.js b/src/utils/captcha.js index 96fdc32..f6bb6d3 100644 --- a/src/utils/captcha.js +++ b/src/utils/captcha.js @@ -52,7 +52,7 @@ export async function checkCaptchaSolution( ) { const ipn = getIPv6Subnet(ip); const key = `capt:${ip}`; - let solution = await redis.getAsync(key); + const solution = await redis.getAsync(key); if (solution) { if (solution.toString('utf8') === captchaTextFilter(text)) { const solvkey = `human:${ipn}`;