From 36d59c98c09595f226b1625ae1fd84c769ecae59 Mon Sep 17 00:00:00 2001 From: Robert Long Date: Tue, 18 Jan 2022 11:47:10 -0800 Subject: [PATCH] Add recaptcha debugging --- src/auth/RegisterPage.jsx | 2 ++ src/auth/useRecaptcha.js | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/auth/RegisterPage.jsx b/src/auth/RegisterPage.jsx index 26a9cce..945ec9a 100644 --- a/src/auth/RegisterPage.jsx +++ b/src/auth/RegisterPage.jsx @@ -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); } } diff --git a/src/auth/useRecaptcha.js b/src/auth/useRecaptcha.js index c7dc4b4..41ae207 100644 --- a/src/auth/useRecaptcha.js +++ b/src/auth/useRecaptcha.js @@ -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]);