Add recaptcha debugging
This commit is contained in:
parent
f6b3d6830e
commit
36d59c98c0
2 changed files with 9 additions and 0 deletions
|
@ -64,7 +64,9 @@ export function RegisterPage() {
|
|||
if (isPasswordlessUser) {
|
||||
await changePassword(password);
|
||||
} else {
|
||||
console.log("executing recaptcha");
|
||||
const recaptchaResponse = await execute();
|
||||
console.log("recaptcha response", recaptchaResponse);
|
||||
await register(userName, password, recaptchaResponse);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ export function useRecaptcha(sitekey) {
|
|||
sitekey,
|
||||
size: "invisible",
|
||||
callback: (response) => {
|
||||
console.log("callback", response);
|
||||
if (promiseRef.current) {
|
||||
promiseRef.current.resolve(response);
|
||||
}
|
||||
|
@ -53,10 +54,12 @@ export function useRecaptcha(sitekey) {
|
|||
|
||||
const execute = useCallback(() => {
|
||||
if (!sitekey) {
|
||||
console.log("no site key");
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
if (!window.grecaptcha) {
|
||||
console.log("Recaptcha not loaded");
|
||||
return Promise.reject(new Error("Recaptcha not loaded"));
|
||||
}
|
||||
|
||||
|
@ -64,6 +67,7 @@ export function useRecaptcha(sitekey) {
|
|||
const observer = new MutationObserver((mutationsList) => {
|
||||
for (const item of mutationsList) {
|
||||
if (item.target.style?.visibility !== "visible") {
|
||||
console.log("Recaptcha dismissed");
|
||||
reject(new Error("Recaptcha dismissed"));
|
||||
observer.disconnect();
|
||||
return;
|
||||
|
@ -73,10 +77,12 @@ export function useRecaptcha(sitekey) {
|
|||
|
||||
promiseRef.current = {
|
||||
resolve: (value) => {
|
||||
console.log("Recaptcha resolved", value);
|
||||
resolve(value);
|
||||
observer.disconnect();
|
||||
},
|
||||
reject: (error) => {
|
||||
console.log("Recaptcha rejected", error);
|
||||
reject(error);
|
||||
observer.disconnect();
|
||||
},
|
||||
|
@ -98,6 +104,7 @@ export function useRecaptcha(sitekey) {
|
|||
|
||||
const reset = useCallback(() => {
|
||||
if (window.grecaptcha) {
|
||||
console.log("Recaptcha reset");
|
||||
window.grecaptcha.reset();
|
||||
}
|
||||
}, [recaptchaId]);
|
||||
|
|
Loading…
Reference in a new issue