From 8db266a413c39e7f58ae469c61adc9889969206a Mon Sep 17 00:00:00 2001 From: Zeeshan Mehboob Date: Fri, 5 Apr 2024 10:59:29 +0530 Subject: [PATCH] [MODIFIED] resetting captchaToken with recaptcha wigdet Signed-off-by: Zeeshan Mehboob --- oidc-ui/src/components/Form.js | 13 +++++++++++-- oidc-ui/src/components/OtpGet.js | 13 +++++++++++-- oidc-ui/src/components/Password.js | 13 +++++++++++-- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/oidc-ui/src/components/Form.js b/oidc-ui/src/components/Form.js index 00b7325f5..f0dc650da 100644 --- a/oidc-ui/src/components/Form.js +++ b/oidc-ui/src/components/Form.js @@ -80,6 +80,15 @@ export default function Form({ setCaptchaToken(value); }; + /** + * Reset the captcha widget + * & its token value + */ + const resetCaptcha = () => { + _reCaptchaRef.current.reset(); + setCaptchaToken(null); + } + //Handle Login API Integration here const authenticateUser = async () => { try { @@ -128,7 +137,7 @@ export default function Form({ errorCode: `${errors[0].errorCode}` }); } - _reCaptchaRef.current.reset(); + resetCaptcha(); return; } else { setError(null); @@ -154,7 +163,7 @@ export default function Form({ defaultMsg: error.message, }); setStatus(states.ERROR); - _reCaptchaRef.current.reset(); + resetCaptcha(); } }; diff --git a/oidc-ui/src/components/OtpGet.js b/oidc-ui/src/components/OtpGet.js index e17a42907..790560485 100644 --- a/oidc-ui/src/components/OtpGet.js +++ b/oidc-ui/src/components/OtpGet.js @@ -89,6 +89,15 @@ export default function OtpGet({ const handleChange = (e) => { setLoginState({ ...loginState, [e.target.id]: e.target.value }); }; + + /** + * Reset the captcha widget + * & its token value + */ + const resetCaptcha = () => { + _reCaptchaRef.current.reset(); + setCaptchaToken(null); + } const sendOTP = async () => { try { @@ -128,7 +137,7 @@ export default function OtpGet({ show: true }); } - _reCaptchaRef.current.reset(); + resetCaptcha(); return; } else { onOtpSent(loginState["Otp_mosip-vid"], response); @@ -140,7 +149,7 @@ export default function OtpGet({ show: true }); setStatus({ state: states.ERROR, msg: "" }); - _reCaptchaRef.current.reset(); + resetCaptcha(); } }; diff --git a/oidc-ui/src/components/Password.js b/oidc-ui/src/components/Password.js index 516c9ab16..615fea32d 100644 --- a/oidc-ui/src/components/Password.js +++ b/oidc-ui/src/components/Password.js @@ -107,6 +107,15 @@ export default function Password({ setCaptchaToken(value); }; + /** + * Reset the captcha widget + * & its token value + */ + const resetCaptcha = () => { + _reCaptchaRef.current.reset(); + setCaptchaToken(null); + } + //Handle Login API Integration here const authenticateUser = async () => { try { @@ -157,7 +166,7 @@ export default function Password({ show: true }); } - _reCaptchaRef.current.reset(); + resetCaptcha(); return; } else { setErrorBanner(null); @@ -182,7 +191,7 @@ export default function Password({ show: true }); setStatus(states.ERROR); - _reCaptchaRef.current.reset(); + resetCaptcha(); } };