From e2afee2045b011bedfbc163907e8b61ccf76510d Mon Sep 17 00:00:00 2001 From: Petru Paler Date: Mon, 12 Jan 2026 13:49:02 +0000 Subject: [PATCH] Add OAuth debugging console.log statements Temporary debugging to diagnose why authWithOAuth2 promise doesn't resolve after successful code exchange. Co-Authored-By: Claude Opus 4.5 --- src/app/login/page.test.tsx | 4 ++++ src/app/login/page.tsx | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/app/login/page.test.tsx b/src/app/login/page.test.tsx index de7ed00..b93dcad 100644 --- a/src/app/login/page.test.tsx +++ b/src/app/login/page.test.tsx @@ -22,6 +22,10 @@ vi.mock("@/lib/pocketbase", () => ({ authWithOAuth2: mockAuthWithOAuth2, listAuthMethods: mockListAuthMethods, }), + authStore: { + isValid: true, + token: "mock-test-token-for-debugging", + }, }, })); diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx index 7a715bc..c8c59d8 100644 --- a/src/app/login/page.tsx +++ b/src/app/login/page.tsx @@ -120,11 +120,22 @@ export default function LoginPage() { setError(null); try { - await pb.collection("users").authWithOAuth2({ provider: "oidc" }); + console.log("[OAuth] Starting authWithOAuth2..."); + const result = await pb + .collection("users") + .authWithOAuth2({ provider: "oidc" }); + console.log("[OAuth] authWithOAuth2 resolved:", result); + console.log("[OAuth] authStore.isValid:", pb.authStore?.isValid); + console.log( + "[OAuth] authStore.token:", + `${pb.authStore?.token?.substring(0, 20)}...`, + ); // Reset attempts on successful login setLoginAttempts([]); + console.log("[OAuth] Calling router.push..."); router.push("/"); } catch (err) { + console.error("[OAuth] Error caught:", err); // Record the failed attempt recordAttempt(); const message =