From 2cf564d28622b9bf5d901f8a06fa01cea4fad730 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Mon, 10 Nov 2025 00:21:30 +0000 Subject: [PATCH] Add error message display from URL query parameters to Login page cgen-13ebb535a8594053b3371bb4cf5a021a --- client/pages/Login.tsx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/client/pages/Login.tsx b/client/pages/Login.tsx index 3cd9331d..e6a14e57 100644 --- a/client/pages/Login.tsx +++ b/client/pages/Login.tsx @@ -142,6 +142,7 @@ export default function Login() { >(null); const [showReset, setShowReset] = useState(false); const [resetEmail, setResetEmail] = useState(""); + const [errorFromUrl, setErrorFromUrl] = useState(null); const navigate = useNavigate(); const location = useLocation(); const { @@ -155,6 +156,29 @@ export default function Login() { } = useAuth(); const { info: toastInfo, error: toastError } = useAethexToast(); + // Check for error messages from URL query parameters (e.g., from OAuth callbacks) + useEffect(() => { + const params = new URLSearchParams(location.search); + const errorType = params.get("error"); + const errorMessage = params.get("message"); + + if (errorType && errorMessage) { + setErrorFromUrl(decodeURIComponent(errorMessage)); + // Show in toast as well + if (errorType === "account_exists") { + toastError({ + title: "Account Already Exists", + description: errorMessage, + }); + } else if (errorType === "auth_create") { + toastError({ + title: "Authentication Error", + description: errorMessage, + }); + } + } + }, [location.search, toastError]); + // After auth resolves and a user exists, navigate to next path or dashboard useEffect(() => { if (!loading && user) {