From 857c3b298043bec7e9f8730d6f722667df4fa527 Mon Sep 17 00:00:00 2001 From: Awesome-E <54484616+Awesome-E@users.noreply.github.com> Date: Sun, 17 Dec 2023 20:08:27 -0800 Subject: [PATCH 01/14] Pass recaptcha token in form on client side --- site/src/component/ReviewForm/ReviewForm.tsx | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/site/src/component/ReviewForm/ReviewForm.tsx b/site/src/component/ReviewForm/ReviewForm.tsx index 045e532a..cee2c7d0 100644 --- a/site/src/component/ReviewForm/ReviewForm.tsx +++ b/site/src/component/ReviewForm/ReviewForm.tsx @@ -57,7 +57,7 @@ const ReviewForm: FC = (props) => { const [textbook, setTextbook] = useState(false); const [attendance, setAttendance] = useState(false); const [selectedTags, setSelectedTags] = useState([]); - const [verified, setVerified] = useState(false); + const [captchaToken, setCaptchaToken] = useState(""); const [submitted, setSubmitted] = useState(false); const [overCharLimit, setOverCharLimit] = useState(false); const [cookies, setCookie] = useCookies(["user"]); @@ -110,7 +110,7 @@ const ReviewForm: FC = (props) => { return; } - if (!verified) { + if (!captchaToken) { alert("Please complete the CAPTCHA"); return; } @@ -136,6 +136,7 @@ const ReviewForm: FC = (props) => { textbook: textbook, attendance: attendance, tags: selectedTags, + captchaToken: captchaToken, verified: false, }; if (content.length > 500) { @@ -424,16 +425,7 @@ const ReviewForm: FC = (props) => { { - // if verified - if (token) { - setVerified(true); - } - // captcha expired - else { - setVerified(false); - } - }} + onChange={(token) => setCaptchaToken(token || "")} />