Skip to content

Commit

Permalink
Merge pull request mosip#648 from Infosys/bug/ES-938
Browse files Browse the repository at this point in the history
[ES-938] resetting captchaToken with recaptcha wigdet
  • Loading branch information
aranaravi authored Apr 5, 2024
2 parents c809469 + 8db266a commit beaceee
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
13 changes: 11 additions & 2 deletions oidc-ui/src/components/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -128,7 +137,7 @@ export default function Form({
errorCode: `${errors[0].errorCode}`
});
}
_reCaptchaRef.current.reset();
resetCaptcha();
return;
} else {
setError(null);
Expand All @@ -154,7 +163,7 @@ export default function Form({
defaultMsg: error.message,
});
setStatus(states.ERROR);
_reCaptchaRef.current.reset();
resetCaptcha();
}
};

Expand Down
13 changes: 11 additions & 2 deletions oidc-ui/src/components/OtpGet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -128,7 +137,7 @@ export default function OtpGet({
show: true
});
}
_reCaptchaRef.current.reset();
resetCaptcha();
return;
} else {
onOtpSent(loginState["Otp_mosip-vid"], response);
Expand All @@ -140,7 +149,7 @@ export default function OtpGet({
show: true
});
setStatus({ state: states.ERROR, msg: "" });
_reCaptchaRef.current.reset();
resetCaptcha();
}
};

Expand Down
13 changes: 11 additions & 2 deletions oidc-ui/src/components/Password.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -157,7 +166,7 @@ export default function Password({
show: true
});
}
_reCaptchaRef.current.reset();
resetCaptcha();
return;
} else {
setErrorBanner(null);
Expand All @@ -182,7 +191,7 @@ export default function Password({
show: true
});
setStatus(states.ERROR);
_reCaptchaRef.current.reset();
resetCaptcha();
}
};

Expand Down

0 comments on commit beaceee

Please sign in to comment.