enter in text field -> submit captcha

This commit is contained in:
HF 2021-03-18 14:41:19 +01:00
parent dd8ceed6e8
commit 9b96e390af
2 changed files with 22 additions and 17 deletions

View File

@ -23,7 +23,19 @@ const Captcha = ({ callback, close }) => {
const [imgLoaded, setImgLoaded] = useState(false);
return (
<div>
<form
onSubmit={async (e) => {
e.preventDefault();
const { errors: resErrors } = await requestSolveCaptcha(text);
if (resErrors) {
setCaptchaUrl(getUrl());
setText('');
setErrors(resErrors);
} else {
close();
}
}}
>
{errors.map((error) => (
<p key={error} className="errormessage">
<span>{t`Error`}</span>:&nbsp;{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 }) => {
<button
type="button"
onClick={close}
style={{fontSize: 16}}
style={{ fontSize: 16 }}
>
{t`Cancel`}
</button>
&nbsp;
<button
type="button"
onClick={async () => {
const { errors: resErrors } = await requestSolveCaptcha(text);
if (resErrors) {
setCaptchaUrl(getUrl());
setText('');
setErrors(resErrors);
} else {
close();
}
}}
style={{fontSize: 16}}
type="submit"
style={{ fontSize: 16 }}
>
{t`Send`}
</button>
</div>
)}
</div>
</form>
);
};

View File

@ -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}`;