Fix-Catch invalid google recaptcha v3 key error (#6034)
* Handle invalid google recaptcha v3 key
This commit is contained in:
parent
22f30d09b0
commit
a8871770c1
|
|
@ -240,12 +240,7 @@ function RecaptchaV3Component(
|
|||
) {
|
||||
// Check if a string is a valid JSON string
|
||||
const checkValidJson = (inputString: string): boolean => {
|
||||
try {
|
||||
JSON.parse(inputString);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
return !inputString.includes('"');
|
||||
};
|
||||
|
||||
const handleBtnClick = (event: React.MouseEvent<HTMLElement>) => {
|
||||
|
|
@ -278,11 +273,9 @@ function RecaptchaV3Component(
|
|||
};
|
||||
|
||||
let validGoogleRecaptchaKey = props.googleRecaptchaKey;
|
||||
|
||||
if (validGoogleRecaptchaKey && checkValidJson(validGoogleRecaptchaKey)) {
|
||||
if (validGoogleRecaptchaKey && !checkValidJson(validGoogleRecaptchaKey)) {
|
||||
validGoogleRecaptchaKey = undefined;
|
||||
}
|
||||
|
||||
const status = useScript(
|
||||
`https://www.google.com/recaptcha/api.js?render=${validGoogleRecaptchaKey}`,
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user