From cabf84f30a283ec31f781ad868bbbb35611e3cc8 Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Fri, 15 Sep 2023 22:12:03 +0200 Subject: [PATCH] docs: update examples --- .../with-account-linking/backend/config.ts | 2 +- .../test/basic.test.js | 6 +++- .../api-server.js | 28 +++++++++++----- .../test/basic.test.js | 6 +++- .../api-server/server.ts | 2 +- .../api-server.js | 4 +-- examples/with-i18next/test/basic.test.js | 6 +++- examples/with-localstorage/test/basic.test.js | 6 +++- .../api-server/epOverride.ts | 32 +++++++++---------- .../api-server/index.ts | 4 +-- .../test/basic.test.js | 12 +++++-- .../.netlify/edge-functions-import-map.json | 8 ++++- examples/with-netlify/test/basic.test.js | 1 + .../api-server/index.js | 1 + .../test/basic.test.js | 6 +++- .../with-phone-password/api-server/index.ts | 12 +++++-- .../with-phone-password/test/basic.test.js | 6 ++-- .../api-server/index.ts | 17 ++++++---- .../test/basic.test.js | 6 +++- .../test/basic.test.js | 6 +++- .../backend/config.ts | 2 +- .../backend/index.ts | 12 ++++--- .../test/basic.test.js | 12 +++++-- package.json | 2 +- 24 files changed, 137 insertions(+), 62 deletions(-) diff --git a/examples/with-account-linking/backend/config.ts b/examples/with-account-linking/backend/config.ts index 4fce9944d..3d03ffb2d 100644 --- a/examples/with-account-linking/backend/config.ts +++ b/examples/with-account-linking/backend/config.ts @@ -23,7 +23,7 @@ export function getWebsiteDomain() { export const SuperTokensConfig: TypeInput = { supertokens: { // this is the location of the SuperTokens core. - connectionURI: "http://localhost:3567", + connectionURI: "https://try.supertokens.com", }, appInfo: { appName: "SuperTokens Demo App", diff --git a/examples/with-emailpassword-vercel/test/basic.test.js b/examples/with-emailpassword-vercel/test/basic.test.js index 48073408c..ba7efd707 100644 --- a/examples/with-emailpassword-vercel/test/basic.test.js +++ b/examples/with-emailpassword-vercel/test/basic.test.js @@ -90,7 +90,11 @@ describe("SuperTokens Example Basic tests", function () { await waitForSTElement(page, "[data-supertokens~='sendVerifyEmailIcon']"); // Create a new token and use it (we don't have access to the originally sent one) - const tokenInfo = await EmailVerification.createEmailVerificationToken("public", userId, email); + const tokenInfo = await EmailVerification.createEmailVerificationToken( + "public", + SuperTokensNode.convertToRecipeUserId(userId), + email + ); await page.goto(`${websiteDomain}/auth/verify-email?token=${tokenInfo.token}`); await submitForm(page); diff --git a/examples/with-emailverification-then-password-thirdpartyemailpassword/api-server.js b/examples/with-emailverification-then-password-thirdpartyemailpassword/api-server.js index 0a8761bf7..da97da89e 100644 --- a/examples/with-emailverification-then-password-thirdpartyemailpassword/api-server.js +++ b/examples/with-emailverification-then-password-thirdpartyemailpassword/api-server.js @@ -74,7 +74,9 @@ supertokens.init({ }; } const res = await oI.emailPasswordSignInPOST(input); - await res.session.setClaimValue(RealPasswordClaim, true, input.userContext); + if (res.status === "OK") { + await res.session.setClaimValue(RealPasswordClaim, true, input.userContext); + } return res; }, emailPasswordSignUpPOST: async function (input) { @@ -101,10 +103,11 @@ supertokens.init({ if (signInResponse.status === "WRONG_CREDENTIALS_ERROR") { return response; } else { - await EmailVerification.unverifyEmail(signInResponse.user.id, email); + await EmailVerification.unverifyEmail(signInResponse.recipeUserId, email); response = { status: "OK", user: signInResponse.user, + recipeUserId: signInResponse.recipeUserId, }; } } @@ -112,23 +115,30 @@ supertokens.init({ // we have just created a user with the fake password. // so we mark their session as unusable by the APIs - await Session.createNewSession( + const newSession = await Session.createNewSession( input.options.req, input.options.res, input.tenantId, - user.id, + response.recipeUserId, { - ...RealPasswordClaim.build(user.id, input.tenantId, input.userContext), + ...RealPasswordClaim.build( + user.id, + response.recipeUserId, + input.tenantId, + input.userContext + ), }, {} ); return { + ...response, status: "OK", user, + session: newSession, }; } else { // session exists.. so the user is trying to change their password now - let userId = session.getUserId(); + let recipeUserId = session.getRecipeUserId(); let password = input.formFields.filter((f) => f.id === "password")[0].value; if (password === FAKE_PASSWORD) { @@ -137,16 +147,18 @@ supertokens.init({ // now we modify the user's password to the new password + change the session to set RealPasswordClaim to true await ThirdPartyEmailPassword.updateEmailOrPassword({ - userId, + recipeUserId, password, }); await session.setClaimValue(RealPasswordClaim, true); - let user = await ThirdPartyEmailPassword.getUserById(userId); + let user = await supertokens.getUser(recipeUserId.getAsString()); return { status: "OK", user, + recipeUserId, + session, }; } }, diff --git a/examples/with-emailverification-then-password-thirdpartyemailpassword/test/basic.test.js b/examples/with-emailverification-then-password-thirdpartyemailpassword/test/basic.test.js index 7e8505be9..5e65c6b15 100644 --- a/examples/with-emailverification-then-password-thirdpartyemailpassword/test/basic.test.js +++ b/examples/with-emailverification-then-password-thirdpartyemailpassword/test/basic.test.js @@ -84,7 +84,11 @@ describe("SuperTokens Example Basic tests", function () { const userId = await page.evaluate(() => window.__supertokensSessionRecipe.getUserId()); // Create a new token and use it (we don't have access to the originally sent one) - const tokenInfo = await EmailVerification.createEmailVerificationToken("public", userId, email); + const tokenInfo = await EmailVerification.createEmailVerificationToken( + "public", + SuperTokensNode.convertToRecipeUserId(userId), + email + ); await page.goto(`${websiteDomain}/auth/verify-email?token=${tokenInfo.token}`); await submitForm(page); diff --git a/examples/with-emailverification-with-otp/api-server/server.ts b/examples/with-emailverification-with-otp/api-server/server.ts index 4fe454064..1b2837c81 100644 --- a/examples/with-emailverification-with-otp/api-server/server.ts +++ b/examples/with-emailverification-with-otp/api-server/server.ts @@ -22,7 +22,7 @@ supertokens.init({ framework: "express", supertokens: { // TODO: This is a core hosted for demo purposes. You can use this, but make sure to change it to your core instance URI eventually. - connectionURI: "https://try.supertokens.io", + connectionURI: "https://try.supertokens.com", apiKey: "", }, appInfo: { diff --git a/examples/with-hasura-thirdpartyemailpassword/api-server.js b/examples/with-hasura-thirdpartyemailpassword/api-server.js index 183af8171..8258e8f30 100644 --- a/examples/with-hasura-thirdpartyemailpassword/api-server.js +++ b/examples/with-hasura-thirdpartyemailpassword/api-server.js @@ -89,12 +89,12 @@ supertokens.init({ return { ...oI, createNewSession: async function (input) { - let userInfo = await ThirdPartyEmailPassword.getUserById(input.userId); + let userInfo = await supertokens.getUser(input.userId); input.accessTokenPayload = { ...input.accessTokenPayload, "https://hasura.io/jwt/claims": { - "x-hasura-user-id": userInfo.email, + "x-hasura-user-id": userInfo.emails[0], "x-hasura-default-role": "user", "x-hasura-allowed-roles": ["user"], }, diff --git a/examples/with-i18next/test/basic.test.js b/examples/with-i18next/test/basic.test.js index 548e2824c..682fca229 100644 --- a/examples/with-i18next/test/basic.test.js +++ b/examples/with-i18next/test/basic.test.js @@ -97,7 +97,11 @@ describe("SuperTokens Example Basic tests", function () { await waitForSTElement(page, "[data-supertokens~='sendVerifyEmailIcon']"); // Create a new token and use it (we don't have access to the originally sent one) - const tokenInfo = await EmailVerification.createEmailVerificationToken("public", userId, email); + const tokenInfo = await EmailVerification.createEmailVerificationToken( + "public", + SuperTokensNode.convertToRecipeUserId(userId), + email + ); await page.goto(`${websiteDomain}/auth/verify-email?token=${tokenInfo.token}`); await submitForm(page); diff --git a/examples/with-localstorage/test/basic.test.js b/examples/with-localstorage/test/basic.test.js index 48073408c..ba7efd707 100644 --- a/examples/with-localstorage/test/basic.test.js +++ b/examples/with-localstorage/test/basic.test.js @@ -90,7 +90,11 @@ describe("SuperTokens Example Basic tests", function () { await waitForSTElement(page, "[data-supertokens~='sendVerifyEmailIcon']"); // Create a new token and use it (we don't have access to the originally sent one) - const tokenInfo = await EmailVerification.createEmailVerificationToken("public", userId, email); + const tokenInfo = await EmailVerification.createEmailVerificationToken( + "public", + SuperTokensNode.convertToRecipeUserId(userId), + email + ); await page.goto(`${websiteDomain}/auth/verify-email?token=${tokenInfo.token}`); await submitForm(page); diff --git a/examples/with-multiple-email-sign-in/api-server/epOverride.ts b/examples/with-multiple-email-sign-in/api-server/epOverride.ts index 3d03c4c14..b37bd0db3 100644 --- a/examples/with-multiple-email-sign-in/api-server/epOverride.ts +++ b/examples/with-multiple-email-sign-in/api-server/epOverride.ts @@ -1,29 +1,27 @@ -import { RecipeInterface } from "supertokens-node/recipe/emailpassword"; +import { APIInterface } from "supertokens-node/recipe/emailpassword"; import { getPrimaryEmailFromInputEmail } from "./emailLinkingMap"; -export function epOverride(oI: RecipeInterface): RecipeInterface { +export function epOverride(oI: APIInterface): APIInterface { return { ...oI, - signIn: async function (input) { - let primaryEmail = getPrimaryEmailFromInputEmail(input.email); - if (primaryEmail !== undefined) { - input.email = primaryEmail; - } - return oI.signIn(input); - }, - signUp: async function (input) { - let primaryEmail = getPrimaryEmailFromInputEmail(input.email); + signInPOST: async function (input) { + const emailField = input.formFields.find((f) => f.id === "email")!; + + let primaryEmail = getPrimaryEmailFromInputEmail(emailField.value); if (primaryEmail !== undefined) { - input.email = primaryEmail; + emailField.value = primaryEmail; } - return oI.signUp(input); + return oI.signInPOST!(input); }, - getUserByEmail: async function (input) { - let primaryEmail = getPrimaryEmailFromInputEmail(input.email); + signUpPOST: async function (input) { + const emailField = input.formFields.find((f) => f.id === "email")!; + + let primaryEmail = getPrimaryEmailFromInputEmail(emailField.value); if (primaryEmail !== undefined) { - input.email = primaryEmail; + emailField.value = primaryEmail; } - return oI.getUserByEmail(input); + + return oI.signUpPOST!(input); }, }; } diff --git a/examples/with-multiple-email-sign-in/api-server/index.ts b/examples/with-multiple-email-sign-in/api-server/index.ts index d92fde8d0..f33112e46 100644 --- a/examples/with-multiple-email-sign-in/api-server/index.ts +++ b/examples/with-multiple-email-sign-in/api-server/index.ts @@ -53,7 +53,7 @@ supertokens.init({ }), EmailPassword.init({ override: { - functions: (oI) => epOverride(oI), + apis: (oI) => epOverride(oI), }, }), Session.init(), @@ -79,7 +79,7 @@ app.use(middleware()); app.post("/add-email", verifySession(), async (req: SessionRequest, res) => { let userId = req.session!.getUserId(); let emailToAdd = req.body.email; - let success = associateNewEmailWithPrimaryEmail(emailToAdd, (await EmailPassword.getUserById(userId))!.email); + let success = associateNewEmailWithPrimaryEmail(emailToAdd, (await supertokens.getUser(userId))!.emails[0]); res.send({ status: success ? "OK" : "INPUT_EMAIL_ASSOCIATED_WITH_ANOTHER_USER", }); diff --git a/examples/with-multiple-email-sign-in/test/basic.test.js b/examples/with-multiple-email-sign-in/test/basic.test.js index 5f3ea42f2..dc99f268f 100644 --- a/examples/with-multiple-email-sign-in/test/basic.test.js +++ b/examples/with-multiple-email-sign-in/test/basic.test.js @@ -90,7 +90,11 @@ describe("SuperTokens Example Basic tests", function () { await waitForSTElement(page, "[data-supertokens~='sendVerifyEmailIcon']"); // Create a new token and use it (we don't have access to the originally sent one) - const tokenInfo = await EmailVerification.createEmailVerificationToken("public", userId, email); + const tokenInfo = await EmailVerification.createEmailVerificationToken( + "public", + SuperTokensNode.convertToRecipeUserId(userId), + email + ); await page.goto(`${websiteDomain}/auth/verify-email?token=${tokenInfo.token}`); await waitForSTElement(page, "[data-supertokens='button']"); await submitForm(page); @@ -121,7 +125,11 @@ describe("SuperTokens Example Basic tests", function () { await submitForm(page); // Redirected to email verification screen await waitForSTElement(page, "[data-supertokens~='sendVerifyEmailIcon']"); - const tokenInfo2 = await EmailVerification.createEmailVerificationToken("public", userId, email2); + const tokenInfo2 = await EmailVerification.createEmailVerificationToken( + "public", + SuperTokensNode.convertToRecipeUserId(userId), + email2 + ); await page.goto(`${websiteDomain}/auth/verify-email?token=${tokenInfo2.token}`); await waitForSTElement(page, "[data-supertokens='button']"); await submitForm(page); diff --git a/examples/with-netlify/.netlify/edge-functions-import-map.json b/examples/with-netlify/.netlify/edge-functions-import-map.json index b2f6de6db..6ac38f509 100644 --- a/examples/with-netlify/.netlify/edge-functions-import-map.json +++ b/examples/with-netlify/.netlify/edge-functions-import-map.json @@ -1 +1,7 @@ -{ "imports": { "netlify:edge": "https://edge.netlify.com/v1/index.ts" } } +{ + "imports": { + "@netlify/edge-functions": "https://edge.netlify.com/v1/index.ts", + "netlify:edge": "https://edge.netlify.com/v1/index.ts?v=legacy" + }, + "scopes": {} +} diff --git a/examples/with-netlify/test/basic.test.js b/examples/with-netlify/test/basic.test.js index 664487aa9..17eee7d77 100644 --- a/examples/with-netlify/test/basic.test.js +++ b/examples/with-netlify/test/basic.test.js @@ -71,6 +71,7 @@ describe("SuperTokens Example Basic tests", function () { describe("Email Password test", function () { it("Successful signup with credentials", async function () { + await new Promise((res) => setTimeout(res, 1000)); await Promise.all([page.goto(websiteDomain), page.waitForNavigation({ waitUntil: "networkidle0" })]); // redirected to /auth diff --git a/examples/with-no-session-on-sign-up-thirdpartyemailpassword/api-server/index.js b/examples/with-no-session-on-sign-up-thirdpartyemailpassword/api-server/index.js index f85c7eb5f..48b909fe8 100644 --- a/examples/with-no-session-on-sign-up-thirdpartyemailpassword/api-server/index.js +++ b/examples/with-no-session-on-sign-up-thirdpartyemailpassword/api-server/index.js @@ -115,6 +115,7 @@ supertokens.init({ getSessionDataFromDatabase: () => null, getTimeCreated: () => -1, getUserId: () => "", + getRecipeUserId: () => input.recipeUserId, revokeSession: () => {}, updateSessionDataInDatabase: () => {}, attachToRequestResponse: () => {}, diff --git a/examples/with-one-login-per-subdomain/test/basic.test.js b/examples/with-one-login-per-subdomain/test/basic.test.js index e9019aa93..32412530a 100644 --- a/examples/with-one-login-per-subdomain/test/basic.test.js +++ b/examples/with-one-login-per-subdomain/test/basic.test.js @@ -95,7 +95,11 @@ describe("SuperTokens Example Basic tests", function () { await waitForSTElement(page, "[data-supertokens~='sendVerifyEmailIcon']"); // Create a new token and use it (we don't have access to the originally sent one) - const tokenInfo = await EmailVerification.createEmailVerificationToken("public", userId, email); + const tokenInfo = await EmailVerification.createEmailVerificationToken( + "public", + SuperTokensNode.convertToRecipeUserId(userId), + email + ); await page.goto(`${websiteDomain}/auth/verify-email?token=${tokenInfo.token}`); await submitForm(page); diff --git a/examples/with-phone-password/api-server/index.ts b/examples/with-phone-password/api-server/index.ts index d0ed7f3a3..4b576262c 100644 --- a/examples/with-phone-password/api-server/index.ts +++ b/examples/with-phone-password/api-server/index.ts @@ -159,6 +159,7 @@ supertokens.init({ // session's payload as PhoneVerifiedClaim: true so that // the user has access to API routes and the frontend UI await session.setClaimValue(PhoneVerifiedClaim, true, input.userContext); + resp.user = (await supertokens.getUser(session.getUserId()))!; } return resp; @@ -187,13 +188,18 @@ supertokens.init({ // we also get the phone number of the user and save it in the // session so that the OTP can be sent to it directly - let userInfo = await EmailPassword.getUserById(input.userId, input.userContext); + let userInfo = await supertokens.getUser(input.userId, input.userContext); return originalImplementation.createNewSession({ ...input, accessTokenPayload: { ...input.accessTokenPayload, - ...PhoneVerifiedClaim.build(input.userId, input.tenantId, input.userContext), - phoneNumber: userInfo?.email, + ...PhoneVerifiedClaim.build( + input.userId, + input.recipeUserId, + input.tenantId, + input.userContext + ), + phoneNumber: userInfo?.emails[0], }, }); } diff --git a/examples/with-phone-password/test/basic.test.js b/examples/with-phone-password/test/basic.test.js index 3d7c04159..084752781 100644 --- a/examples/with-phone-password/test/basic.test.js +++ b/examples/with-phone-password/test/basic.test.js @@ -68,9 +68,9 @@ describe("SuperTokens Example Basic tests", function () { const testOTP = "test123456"; before(async function () { - const user = await EmailPassword.getUserByEmail("public", phoneNumber); - if (user) { - await SuperTokensNode.deleteUser(user.id); + const user = await SuperTokensNode.listUsersByAccountInfo("public", { email: phoneNumber }); + if (user.length > 0) { + await SuperTokensNode.deleteUser(user[0].id); } browser = await puppeteer.launch({ diff --git a/examples/with-thirdpartyemailpassword-2fa-passwordless/api-server/index.ts b/examples/with-thirdpartyemailpassword-2fa-passwordless/api-server/index.ts index bb8146fd5..2d3e6eef4 100644 --- a/examples/with-thirdpartyemailpassword-2fa-passwordless/api-server/index.ts +++ b/examples/with-thirdpartyemailpassword-2fa-passwordless/api-server/index.ts @@ -185,17 +185,22 @@ supertokens.init({ // we alreay have a phone number associated with this user, // so we will add it to the access token payload so that // we can send an OTP to it without asking the end user. - let passwordlessUserInfo = await Passwordless.getUserById({ - userId: userMetadata.metadata.passwordlessUserId as string, - userContext: input.userContext, - }); - phoneNumber = passwordlessUserInfo?.phoneNumber; + let passwordlessUserInfo = await supertokens.getUser( + userMetadata.metadata.passwordlessUserId as string, + input.userContext + ); + phoneNumber = passwordlessUserInfo?.phoneNumbers[0]; } return originalImplementation.createNewSession({ ...input, accessTokenPayload: { ...input.accessTokenPayload, - ...(await SecondFactorClaim.build(input.userId, input.tenantId, input.userContext)), + ...(await SecondFactorClaim.build( + input.userId, + input.recipeUserId, + input.tenantId, + input.userContext + )), phoneNumber, }, }); diff --git a/examples/with-thirdpartyemailpassword-2fa-passwordless/test/basic.test.js b/examples/with-thirdpartyemailpassword-2fa-passwordless/test/basic.test.js index 9cce15fa1..e5760ff5a 100644 --- a/examples/with-thirdpartyemailpassword-2fa-passwordless/test/basic.test.js +++ b/examples/with-thirdpartyemailpassword-2fa-passwordless/test/basic.test.js @@ -139,7 +139,11 @@ describe("SuperTokens Example Basic tests", function () { await waitForSTElement(page, "[data-supertokens~='sendVerifyEmailIcon']"); // Create a new token and use it (we don't have access to the originally sent one) - const tokenInfo = await EmailVerification.createEmailVerificationToken("public", userId, email); + const tokenInfo = await EmailVerification.createEmailVerificationToken( + "public", + SuperTokensNode.convertToRecipeUserId(userId), + email + ); await page.goto(`${websiteDomain}/auth/verify-email?token=${tokenInfo.token}`); await submitForm(page); diff --git a/examples/with-thirdpartyemailpassword-passwordless/test/basic.test.js b/examples/with-thirdpartyemailpassword-passwordless/test/basic.test.js index d53ab4b62..ab3cf8d03 100644 --- a/examples/with-thirdpartyemailpassword-passwordless/test/basic.test.js +++ b/examples/with-thirdpartyemailpassword-passwordless/test/basic.test.js @@ -100,7 +100,11 @@ describe("SuperTokens Example Basic tests", function () { await waitForSTElement(page, "[data-supertokens~='sendVerifyEmailIcon']"); // Create a new token and use it (we don't have access to the originally sent one) - const tokenInfo = await EmailVerification.createEmailVerificationToken("public", userId, email); + const tokenInfo = await EmailVerification.createEmailVerificationToken( + "public", + SuperTokensNode.convertToRecipeUserId(userId), + email + ); await page.goto(`${websiteDomain}/auth/verify-email?token=${tokenInfo.token}`); await submitForm(page); diff --git a/examples/with-update-email-post-verification/backend/config.ts b/examples/with-update-email-post-verification/backend/config.ts index 3c838bca3..0ff7093f3 100644 --- a/examples/with-update-email-post-verification/backend/config.ts +++ b/examples/with-update-email-post-verification/backend/config.ts @@ -44,7 +44,7 @@ export const SuperTokensConfig: TypeInput = { // This will update the email of the user to the one // that was just marked as verified by the token. await EmailPassword.updateEmailOrPassword({ - userId: response.user.id, + recipeUserId: response.user.recipeUserId, email: response.user.email, }); } diff --git a/examples/with-update-email-post-verification/backend/index.ts b/examples/with-update-email-post-verification/backend/index.ts index 34a443dfc..7938d48c8 100644 --- a/examples/with-update-email-post-verification/backend/index.ts +++ b/examples/with-update-email-post-verification/backend/index.ts @@ -37,12 +37,12 @@ app.get("/sessioninfo", verifySession(), async (req: SessionRequest, res) => { app.get("/email", verifySession(), async (req: SessionRequest, res) => { let userId = req.session!.getUserId(); - let user = await EmailPassword.getUserById(userId); + let user = await supertokens.getUser(userId); if (user === undefined) { throw new Error("Should never come here"); } - return res.send(user.email); + return res.send(user.emails[0]); }); // This API is called from the frontend when the user enters their new email. @@ -58,7 +58,8 @@ app.post("/change-email", verifySession(), async (req: SessionRequest, res) => { // First we check if the new email is already associated with another user. // If it is, then we throw an error. If it's already associated with this user, // then we return a success response with an appropriate message. - let existingUser = await EmailPassword.getUserByEmail(session.getTenantId(), email); + let users = await supertokens.listUsersByAccountInfo(session.getTenantId(), { email }); + const existingUser = users[0]; if (existingUser !== undefined) { if (existingUser.id === session.getUserId()) { return res.status(200).send("Email already belongs to this account"); @@ -70,13 +71,14 @@ app.post("/change-email", verifySession(), async (req: SessionRequest, res) => { // Then, we check if the email is verified for this user ID or not. // It is important to understand that SuperTokens stores email verification // status based on the user ID AND the email, and not just the email. - let isVerified = await EmailVerification.isEmailVerified(session.getUserId(), email); + let isVerified = await EmailVerification.isEmailVerified(session.getRecipeUserId(), email); if (!isVerified) { // Now we send the email verification link to the user for the new email. const sendEmailRes = await EmailVerification.sendEmailVerificationEmail( session.getTenantId(), session.getUserId(), + session.getRecipeUserId(), email ); @@ -89,7 +91,7 @@ app.post("/change-email", verifySession(), async (req: SessionRequest, res) => { // Since the email is verified, we try and do an update let resp = await EmailPassword.updateEmailOrPassword({ - userId: session.getUserId(), + recipeUserId: session.getRecipeUserId(), email: email, }); diff --git a/examples/with-update-email-post-verification/test/basic.test.js b/examples/with-update-email-post-verification/test/basic.test.js index 55eb0f72f..538dde75f 100644 --- a/examples/with-update-email-post-verification/test/basic.test.js +++ b/examples/with-update-email-post-verification/test/basic.test.js @@ -90,7 +90,11 @@ describe("SuperTokens Example Basic tests", function () { await waitForSTElement(page, "[data-supertokens~='sendVerifyEmailIcon']"); // Create a new token and use it (we don't have access to the originally sent one) - const tokenInfo = await EmailVerification.createEmailVerificationToken("public", userId, email); + const tokenInfo = await EmailVerification.createEmailVerificationToken( + "public", + SuperTokensNode.convertToRecipeUserId(userId), + email + ); await page.goto(`${websiteDomain}/auth/verify-email?token=${tokenInfo.token}`); await submitForm(page); @@ -131,7 +135,11 @@ describe("SuperTokens Example Basic tests", function () { const alertText = await alertContent; assert(alertText === "Email verification email sent"); - const tokenInfo = await EmailVerification.createEmailVerificationToken("public", userId, newEmail); + const tokenInfo = await EmailVerification.createEmailVerificationToken( + "public", + SuperTokensNode.convertToRecipeUserId(userId), + newEmail + ); await page.goto(`${websiteDomain}/auth/verify-email?token=${tokenInfo.token}`); await submitForm(page); diff --git a/package.json b/package.json index 4d2e1a4b4..c1eb63a6b 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0", - "supertokens-web-js": "^0.7.0" + "supertokens-web-js": "^0.8.0" }, "scripts": { "init": "bash ./init.sh",