diff --git a/app/components/SuperTokensAuthComponent.tsx b/app/components/SuperTokensAuthComponent.tsx index 97227ac..e0cb8c4 100644 --- a/app/components/SuperTokensAuthComponent.tsx +++ b/app/components/SuperTokensAuthComponent.tsx @@ -1,24 +1,12 @@ "use client"; -import { useEffect, useState } from "react"; -import { doesSessionExist } from "supertokens-web-js/recipe/thirdpartyemailpassword"; -import { useRouter } from "next/navigation"; +import { useState } from "react"; 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(() => { - // Check if user is already logged in - doesSessionExist().then((exists) => { - if (exists) { - router.push("/marks-account/projects"); - } - }); - }, [router]); - const handleGoogleSignIn = async () => { setIsLoading(true); try { diff --git a/lib/supertokens/backendConfig.ts b/lib/supertokens/backendConfig.ts index 2ee6006..17cd884 100644 --- a/lib/supertokens/backendConfig.ts +++ b/lib/supertokens/backendConfig.ts @@ -1,4 +1,5 @@ -import ThirdPartyEmailPasswordNode from "supertokens-node/recipe/thirdpartyemailpassword"; +import ThirdPartyNode from "supertokens-node/recipe/thirdparty"; +import EmailPasswordNode from "supertokens-node/recipe/emailpassword"; import SessionNode from "supertokens-node/recipe/session"; import { TypeInput } from "supertokens-node/types"; import { AppInfoUserInput } from "supertokens-node/types"; @@ -20,28 +21,31 @@ export const backendConfig = (): TypeInput => { }, appInfo, recipeList: [ - ThirdPartyEmailPasswordNode.init({ - providers: [ - { - config: { - thirdPartyId: "google", - clients: [{ - clientId: process.env.GOOGLE_CLIENT_ID || "", - clientSecret: process.env.GOOGLE_CLIENT_SECRET || "", - }], + ThirdPartyNode.init({ + signInAndUpFeature: { + providers: [ + { + config: { + thirdPartyId: "google", + clients: [{ + clientId: process.env.GOOGLE_CLIENT_ID || "", + clientSecret: process.env.GOOGLE_CLIENT_SECRET || "", + }], + }, }, - }, - { - config: { - thirdPartyId: "github", - clients: [{ - clientId: process.env.GITHUB_CLIENT_ID || "", - clientSecret: process.env.GITHUB_CLIENT_SECRET || "", - }], + { + config: { + thirdPartyId: "github", + clients: [{ + clientId: process.env.GITHUB_CLIENT_ID || "", + clientSecret: process.env.GITHUB_CLIENT_SECRET || "", + }], + }, }, - }, - ], + ], + }, }), + EmailPasswordNode.init(), SessionNode.init(), ], isInServerlessEnv: true, diff --git a/lib/supertokens/frontendConfig.ts b/lib/supertokens/frontendConfig.ts index 8877f1f..a5df7dc 100644 --- a/lib/supertokens/frontendConfig.ts +++ b/lib/supertokens/frontendConfig.ts @@ -1,7 +1,5 @@ -import ThirdPartyEmailPassword, { - Google, - Github, -} from "supertokens-auth-react/recipe/thirdpartyemailpassword"; +import ThirdParty, { Google, Github } from "supertokens-auth-react/recipe/thirdparty"; +import EmailPassword from "supertokens-auth-react/recipe/emailpassword"; import Session from "supertokens-auth-react/recipe/session"; export const frontendConfig = () => { @@ -16,7 +14,7 @@ export const frontendConfig = () => { websiteBasePath: "/auth", }, recipeList: [ - ThirdPartyEmailPassword.init({ + ThirdParty.init({ signInAndUpFeature: { providers: [ Google.init(), @@ -24,6 +22,7 @@ export const frontendConfig = () => { ], }, }), + EmailPassword.init(), Session.init(), ], };