Unverified Commit 4fbf3d37 authored by Rishabh Poddar's avatar Rishabh Poddar Committed by GitHub

Update to with-supertokens example (#66320)

Updates to using latest supertokens' SDK versions.
Co-authored-by: 's avatarSam Ko <sam@vercel.com>
parent 3d2494a3
...@@ -60,7 +60,8 @@ export async function HomePage() { ...@@ -60,7 +60,8 @@ export async function HomePage() {
if (hasInvalidClaims) { if (hasInvalidClaims) {
return <SessionAuthForNextJS />; return <SessionAuthForNextJS />;
} else { } else {
return <TryRefreshComponent />; // To learn about why the 'key' attribute is required refer to: https://github.com/supertokens/supertokens-node/issues/826#issuecomment-2092144048
return <TryRefreshComponent key={Date.now()} />;
} }
} }
......
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 Dashboard from "supertokens-node/recipe/dashboard"; import Dashboard from "supertokens-node/recipe/dashboard";
import UserRoles from "supertokens-node/recipe/userroles"; import UserRoles from "supertokens-node/recipe/userroles";
...@@ -16,62 +17,65 @@ export let backendConfig = (): TypeInput => { ...@@ -16,62 +17,65 @@ export let backendConfig = (): TypeInput => {
// recipeList contains all the modules that you want to // recipeList contains all the modules that you want to
// use from SuperTokens. See the full list here: https://supertokens.com/docs/guides // use from SuperTokens. See the full list here: https://supertokens.com/docs/guides
recipeList: [ recipeList: [
ThirdPartyEmailPasswordNode.init({ EmailPasswordNode.init(),
providers: [ ThirdPartyNode.init({
// We have provided you with development keys which you can use for testing. signInAndUpFeature: {
// IMPORTANT: Please replace them with your own OAuth keys for production use. providers: [
{ // We have provided you with development keys which you can use for testing.
config: { // IMPORTANT: Please replace them with your own OAuth keys for production use.
thirdPartyId: "google", {
clients: [ config: {
{ thirdPartyId: "google",
clientId: clients: [
"1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com", {
clientSecret: "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", clientId:
}, "1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com",
], clientSecret: "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",
},
],
},
}, },
}, {
{ config: {
config: { thirdPartyId: "github",
thirdPartyId: "github", clients: [
clients: [ {
{ clientId: "467101b197249757c71f",
clientId: "467101b197249757c71f", clientSecret: "e97051221f4b6426e8fe8d51486396703012f5bd",
clientSecret: "e97051221f4b6426e8fe8d51486396703012f5bd", },
}, ],
], },
}, },
}, {
{ config: {
config: { thirdPartyId: "apple",
thirdPartyId: "apple", clients: [
clients: [ {
{ clientId: "4398792-io.supertokens.example.service",
clientId: "4398792-io.supertokens.example.service", additionalConfig: {
additionalConfig: { keyId: "7M48Y4RYDL",
keyId: "7M48Y4RYDL", privateKey:
privateKey: "-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n-----END PRIVATE KEY-----",
"-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n-----END PRIVATE KEY-----", teamId: "YWQCXGJRJL",
teamId: "YWQCXGJRJL", },
}, },
}, ],
], },
}, },
}, {
{ config: {
config: { thirdPartyId: "twitter",
thirdPartyId: "twitter", clients: [
clients: [ {
{ clientId: "4398792-WXpqVXRiazdRMGNJdEZIa3RVQXc6MTpjaQ",
clientId: "4398792-WXpqVXRiazdRMGNJdEZIa3RVQXc6MTpjaQ", clientSecret:
clientSecret: "BivMbtwmcygbRLNQ0zk45yxvW246tnYnTFFq-LH39NwZMxFpdC",
"BivMbtwmcygbRLNQ0zk45yxvW246tnYnTFFq-LH39NwZMxFpdC", },
}, ],
], },
}, },
}, ],
], },
}), }),
SessionNode.init(), SessionNode.init(),
Dashboard.init(), Dashboard.init(),
......
import ThirdPartyEmailPasswordReact from "supertokens-auth-react/recipe/thirdpartyemailpassword"; import ThirdPartyReact from "supertokens-auth-react/recipe/thirdparty";
import EmailPasswordReact from "supertokens-auth-react/recipe/emailpassword";
import Session from "supertokens-auth-react/recipe/session"; import Session from "supertokens-auth-react/recipe/session";
import { appInfo } from "./appInfo"; import { appInfo } from "./appInfo";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { SuperTokensConfig } from "supertokens-auth-react/lib/build/types"; import { SuperTokensConfig } from "supertokens-auth-react/lib/build/types";
import { ThirdPartyEmailPasswordPreBuiltUI } from "supertokens-auth-react/recipe/thirdpartyemailpassword/prebuiltui"; import { ThirdPartyPreBuiltUI } from "supertokens-auth-react/recipe/thirdparty/prebuiltui";
import { EmailPasswordPreBuiltUI } from "supertokens-auth-react/recipe/emailpassword/prebuiltui";
const routerInfo: { router?: ReturnType<typeof useRouter>; pathName?: string } = const routerInfo: { router?: ReturnType<typeof useRouter>; pathName?: string } =
{}; {};
...@@ -20,12 +22,13 @@ export const frontendConfig = (): SuperTokensConfig => { ...@@ -20,12 +22,13 @@ export const frontendConfig = (): SuperTokensConfig => {
return { return {
appInfo, appInfo,
recipeList: [ recipeList: [
ThirdPartyEmailPasswordReact.init({ EmailPasswordReact.init(),
ThirdPartyReact.init({
signInAndUpFeature: { signInAndUpFeature: {
providers: [ providers: [
ThirdPartyEmailPasswordReact.Google.init(), ThirdPartyReact.Google.init(),
ThirdPartyEmailPasswordReact.Github.init(), ThirdPartyReact.Github.init(),
ThirdPartyEmailPasswordReact.Apple.init(), ThirdPartyReact.Apple.init(),
], ],
}, },
}), }),
...@@ -49,4 +52,4 @@ export const recipeDetails = { ...@@ -49,4 +52,4 @@ export const recipeDetails = {
docsLink: "https://supertokens.com/docs/thirdpartyemailpassword/introduction", docsLink: "https://supertokens.com/docs/thirdpartyemailpassword/introduction",
}; };
export const PreBuiltUIList = [ThirdPartyEmailPasswordPreBuiltUI]; export const PreBuiltUIList = [ThirdPartyPreBuiltUI, EmailPasswordPreBuiltUI];
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
"@types/react-dom": "^18", "@types/react-dom": "^18",
"eslint": "^8", "eslint": "^8",
"eslint-config-next": "13.5.4", "eslint-config-next": "13.5.4",
"i": "^0.3.7",
"npm": "^10.2.0",
"typescript": "^5" "typescript": "^5"
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment