From abddadce94c1bd47f4eebacef1fca2c5b81f64b7 Mon Sep 17 00:00:00 2001 From: Mark Henderson Date: Mon, 16 Feb 2026 16:02:18 -0800 Subject: [PATCH] Fix SuperTokens auth component for Google OAuth Co-authored-by: Cursor --- app/components/SuperTokensAuthComponent.tsx | 104 +++++++++++++++++--- 1 file changed, 93 insertions(+), 11 deletions(-) diff --git a/app/components/SuperTokensAuthComponent.tsx b/app/components/SuperTokensAuthComponent.tsx index 0b98ded..97227ac 100644 --- a/app/components/SuperTokensAuthComponent.tsx +++ b/app/components/SuperTokensAuthComponent.tsx @@ -1,20 +1,102 @@ "use client"; -import { useEffect } from "react"; -import { redirectToAuth } from "supertokens-auth-react"; -import { ThirdPartyEmailPasswordPreBuiltUI } from "supertokens-auth-react/recipe/thirdpartyemailpassword/prebuiltui"; -import { canHandleRoute, getRoutingComponent } from "supertokens-auth-react/ui"; +import { useEffect, useState } from "react"; +import { doesSessionExist } from "supertokens-web-js/recipe/thirdpartyemailpassword"; +import { useRouter } from "next/navigation"; +import { Button } from "@/components/ui/button"; +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; export default function SuperTokensAuthComponent() { + const router = useRouter(); + const [isLoading, setIsLoading] = useState(false); + useEffect(() => { - if (!canHandleRoute([ThirdPartyEmailPasswordPreBuiltUI])) { - redirectToAuth(); + // Check if user is already logged in + doesSessionExist().then((exists) => { + if (exists) { + router.push("/marks-account/projects"); + } + }); + }, [router]); + + const handleGoogleSignIn = async () => { + setIsLoading(true); + try { + // Get Google OAuth URL from SuperTokens + const response = await fetch("/api/auth/authorisationurl?thirdPartyId=google"); + const data = await response.json(); + + if (data.status === "OK") { + // Redirect to Google OAuth + window.location.href = data.urlWithQueryParams; + } else { + console.error("Failed to get auth URL:", data); + setIsLoading(false); + } + } catch (error) { + console.error("Google sign-in error:", error); + setIsLoading(false); } - }, []); + }; - if (canHandleRoute([ThirdPartyEmailPasswordPreBuiltUI])) { - return getRoutingComponent([ThirdPartyEmailPasswordPreBuiltUI]); - } + return ( +
+
+ {/* Logo */} +
+ Vib'n +
- return
Loading...
; + {/* Auth Card */} + + + + Welcome to Vib'n + + + Sign in to continue + + + + + + + + {/* Footer */} +

+ By continuing, you agree to our Terms of Service and Privacy Policy. +

+
+
+ ); }