Fix SuperTokens to use separate ThirdParty and EmailPassword recipes
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,24 +1,12 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useState } from "react";
|
||||||
import { doesSessionExist } from "supertokens-web-js/recipe/thirdpartyemailpassword";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
|
|
||||||
export default function SuperTokensAuthComponent() {
|
export default function SuperTokensAuthComponent() {
|
||||||
const router = useRouter();
|
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
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 () => {
|
const handleGoogleSignIn = async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -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 SessionNode from "supertokens-node/recipe/session";
|
||||||
import { TypeInput } from "supertokens-node/types";
|
import { TypeInput } from "supertokens-node/types";
|
||||||
import { AppInfoUserInput } from "supertokens-node/types";
|
import { AppInfoUserInput } from "supertokens-node/types";
|
||||||
@@ -20,7 +21,8 @@ export const backendConfig = (): TypeInput => {
|
|||||||
},
|
},
|
||||||
appInfo,
|
appInfo,
|
||||||
recipeList: [
|
recipeList: [
|
||||||
ThirdPartyEmailPasswordNode.init({
|
ThirdPartyNode.init({
|
||||||
|
signInAndUpFeature: {
|
||||||
providers: [
|
providers: [
|
||||||
{
|
{
|
||||||
config: {
|
config: {
|
||||||
@@ -41,7 +43,9 @@ export const backendConfig = (): TypeInput => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
|
EmailPasswordNode.init(),
|
||||||
SessionNode.init(),
|
SessionNode.init(),
|
||||||
],
|
],
|
||||||
isInServerlessEnv: true,
|
isInServerlessEnv: true,
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import ThirdPartyEmailPassword, {
|
import ThirdParty, { Google, Github } from "supertokens-auth-react/recipe/thirdparty";
|
||||||
Google,
|
import EmailPassword from "supertokens-auth-react/recipe/emailpassword";
|
||||||
Github,
|
|
||||||
} from "supertokens-auth-react/recipe/thirdpartyemailpassword";
|
|
||||||
import Session from "supertokens-auth-react/recipe/session";
|
import Session from "supertokens-auth-react/recipe/session";
|
||||||
|
|
||||||
export const frontendConfig = () => {
|
export const frontendConfig = () => {
|
||||||
@@ -16,7 +14,7 @@ export const frontendConfig = () => {
|
|||||||
websiteBasePath: "/auth",
|
websiteBasePath: "/auth",
|
||||||
},
|
},
|
||||||
recipeList: [
|
recipeList: [
|
||||||
ThirdPartyEmailPassword.init({
|
ThirdParty.init({
|
||||||
signInAndUpFeature: {
|
signInAndUpFeature: {
|
||||||
providers: [
|
providers: [
|
||||||
Google.init(),
|
Google.init(),
|
||||||
@@ -24,6 +22,7 @@ export const frontendConfig = () => {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
EmailPassword.init(),
|
||||||
Session.init(),
|
Session.init(),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user