mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-12 01:08:29 +03:00
fix: reset captcha if you fail to login
This commit is contained in:
@@ -6,7 +6,7 @@ import CenterPage from "components/util/CenterPage";
|
||||
import SiteWordmark from "components/util/SiteWordmark";
|
||||
import { UserContext } from "context/UserContext";
|
||||
import { useFormik } from "formik";
|
||||
import React, { useContext, useState } from "react";
|
||||
import React, { useContext, useRef, useState } from "react";
|
||||
import { Button, Col, Form } from "react-bootstrap";
|
||||
import ReCAPTCHA from "react-google-recaptcha";
|
||||
import toast from "react-hot-toast";
|
||||
@@ -20,6 +20,8 @@ export default function LoginPage() {
|
||||
const { setUser } = useContext(UserContext);
|
||||
const history = useHistory();
|
||||
|
||||
const recaptchaRef = useRef<any>(null);
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
username: "",
|
||||
@@ -42,6 +44,8 @@ export default function LoginPage() {
|
||||
false
|
||||
);
|
||||
|
||||
recaptchaRef.current.reset();
|
||||
|
||||
if (!rj.success) {
|
||||
setErr(HumaniseError(rj.description));
|
||||
return;
|
||||
@@ -111,6 +115,7 @@ export default function LoginPage() {
|
||||
</Form.Group>
|
||||
|
||||
<ReCAPTCHA
|
||||
ref={recaptchaRef}
|
||||
sitekey={
|
||||
process.env.REACT_APP_RECAPTCHA_KEY ??
|
||||
"6LdI2swUAAAAAArkM0ZQi4SnttilqgAwsJSFw3PX"
|
||||
|
||||
Reference in New Issue
Block a user