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
|
// Check if a string is a valid JSON string
|
||||||
const checkValidJson = (inputString: string): boolean => {
|
const checkValidJson = (inputString: string): boolean => {
|
||||||
try {
|
return !inputString.includes('"');
|
||||||
JSON.parse(inputString);
|
|
||||||
return true;
|
|
||||||
} catch (err) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleBtnClick = (event: React.MouseEvent<HTMLElement>) => {
|
const handleBtnClick = (event: React.MouseEvent<HTMLElement>) => {
|
||||||
|
|
@ -278,11 +273,9 @@ function RecaptchaV3Component(
|
||||||
};
|
};
|
||||||
|
|
||||||
let validGoogleRecaptchaKey = props.googleRecaptchaKey;
|
let validGoogleRecaptchaKey = props.googleRecaptchaKey;
|
||||||
|
if (validGoogleRecaptchaKey && !checkValidJson(validGoogleRecaptchaKey)) {
|
||||||
if (validGoogleRecaptchaKey && checkValidJson(validGoogleRecaptchaKey)) {
|
|
||||||
validGoogleRecaptchaKey = undefined;
|
validGoogleRecaptchaKey = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const status = useScript(
|
const status = useScript(
|
||||||
`https://www.google.com/recaptcha/api.js?render=${validGoogleRecaptchaKey}`,
|
`https://www.google.com/recaptcha/api.js?render=${validGoogleRecaptchaKey}`,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user