From bfbc1101e213154554f0181a439f4da70e15f73d Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Wed, 23 Aug 2023 05:03:48 +0200 Subject: [PATCH] feat: remove/reorder tenantId params in account linking --- .../with-account-linking/backend/index.ts | 6 +- lib/build/recipe/accountlinking/index.d.ts | 9 +- lib/build/recipe/accountlinking/index.js | 11 +- lib/build/recipe/accountlinking/recipe.d.ts | 1 - lib/build/recipe/accountlinking/recipe.js | 9 +- .../accountlinking/recipeImplementation.js | 5 +- lib/build/recipe/accountlinking/types.d.ts | 10 +- .../emailpassword/recipeImplementation.js | 2 - .../passwordless/recipeImplementation.js | 1 - .../recipe/thirdparty/recipeImplementation.js | 1 - lib/ts/recipe/accountlinking/index.ts | 16 +- lib/ts/recipe/accountlinking/recipe.ts | 10 +- .../accountlinking/recipeImplementation.ts | 5 +- lib/ts/recipe/accountlinking/types.ts | 10 +- .../emailpassword/recipeImplementation.ts | 2 - .../passwordless/recipeImplementation.ts | 1 - .../recipe/thirdparty/recipeImplementation.ts | 1 - test/accountlinking/emailpassword.test.js | 18 +- test/accountlinking/emailpasswordapis.test.js | 2 +- .../accountlinking/emailpasswordapis2.test.js | 40 ++-- test/accountlinking/emailverification.test.js | 2 +- .../emailverificationapis.test.js | 4 +- test/accountlinking/helperFunctions.test.js | 179 +++++++++--------- test/accountlinking/multitenancy.test.js | 4 +- test/accountlinking/passwordlessapis.test.js | 2 - test/accountlinking/recipeFunction.test.js | 43 ++--- test/accountlinking/session.test.js | 38 ++-- test/accountlinking/thirdparty.test.js | 2 +- test/accountlinking/thirdpartyapis.test.js | 1 - test/dashboard.test.js | 30 +-- test/with-typescript/index.ts | 2 +- 31 files changed, 197 insertions(+), 270 deletions(-) diff --git a/examples/with-account-linking/backend/index.ts b/examples/with-account-linking/backend/index.ts index b36f15694..8f9b6291d 100644 --- a/examples/with-account-linking/backend/index.ts +++ b/examples/with-account-linking/backend/index.ts @@ -116,7 +116,7 @@ app.post("/addPassword", verifySession(), async (req: SessionRequest, res) => { await EmailVerification.verifyEmailUsingToken(session.getTenantId(), tokenResp.token, false); } - const linkResp = await AccountLinking.linkAccounts(session.getTenantId(), newRecipeUserId, session.getUserId()); + const linkResp = await AccountLinking.linkAccounts(newRecipeUserId, session.getUserId()); if (linkResp.status !== "OK") { return res.json({ status: "GENERAL_ERROR", @@ -223,7 +223,7 @@ app.post("/addThirdPartyUser", verifySession(), async (req: SessionRequest, res) await EmailVerification.verifyEmailUsingToken(session.getTenantId(), tokenResp.token, false); } - const linkResp = await AccountLinking.linkAccounts(session.getTenantId(), newRecipeUserId, session.getUserId()); + const linkResp = await AccountLinking.linkAccounts(newRecipeUserId, session.getUserId()); if (linkResp.status !== "OK") { return res.json({ status: "GENERAL_ERROR", @@ -285,7 +285,7 @@ app.post("/addPhoneNumber", verifySession(), async (req: SessionRequest, res) => } const newRecipeUserId = signUpResp.user.loginMethods[0].recipeUserId; - const linkResp = await AccountLinking.linkAccounts(session.getTenantId(), newRecipeUserId, session.getUserId()); + const linkResp = await AccountLinking.linkAccounts(newRecipeUserId, session.getUserId()); if (linkResp.status !== "OK") { return res.json({ status: "GENERAL_ERROR", diff --git a/lib/build/recipe/accountlinking/index.d.ts b/lib/build/recipe/accountlinking/index.d.ts index 98bbbd9d2..1478ad6af 100644 --- a/lib/build/recipe/accountlinking/index.d.ts +++ b/lib/build/recipe/accountlinking/index.d.ts @@ -14,8 +14,8 @@ export default class Wrapper { * no linking that happened. */ static createPrimaryUserIdOrLinkAccounts( - recipeUserId: RecipeUserId, tenantId: string, + recipeUserId: RecipeUserId, userContext?: any ): Promise; /** @@ -91,7 +91,6 @@ export default class Wrapper { } >; static linkAccounts( - tenantId: string, recipeUserId: RecipeUserId, primaryUserId: string, userContext?: any @@ -123,17 +122,17 @@ export default class Wrapper { wasLinked: boolean; }>; static isSignUpAllowed( + tenantId: string, newUser: AccountInfoWithRecipeId, isVerified: boolean, - tenantId: string, userContext?: any ): Promise; - static isSignInAllowed(recipeUserId: RecipeUserId, tenantId: string, userContext?: any): Promise; + static isSignInAllowed(tenantId: string, recipeUserId: RecipeUserId, userContext?: any): Promise; static isEmailChangeAllowed( + tenantId: string, recipeUserId: RecipeUserId, newEmail: string, isVerified: boolean, - tenantId: string, userContext?: any ): Promise; } diff --git a/lib/build/recipe/accountlinking/index.js b/lib/build/recipe/accountlinking/index.js index 6a0718af5..3c8ed6afe 100644 --- a/lib/build/recipe/accountlinking/index.js +++ b/lib/build/recipe/accountlinking/index.js @@ -32,7 +32,7 @@ class Wrapper { * same as the input recipeUserId if it was made into a primary user, or if there was * no linking that happened. */ - static async createPrimaryUserIdOrLinkAccounts(recipeUserId, tenantId, userContext = {}) { + static async createPrimaryUserIdOrLinkAccounts(tenantId, recipeUserId, userContext = {}) { const user = await __1.getUser(recipeUserId.getAsString(), userContext); if (user === undefined) { // Should never really come here unless a programming error happened in the app @@ -84,9 +84,8 @@ class Wrapper { userContext, }); } - static async linkAccounts(tenantId, recipeUserId, primaryUserId, userContext = {}) { + static async linkAccounts(recipeUserId, primaryUserId, userContext = {}) { return await recipe_1.default.getInstance().recipeInterfaceImpl.linkAccounts({ - tenantId, recipeUserId, primaryUserId, userContext, @@ -98,7 +97,7 @@ class Wrapper { userContext, }); } - static async isSignUpAllowed(newUser, isVerified, tenantId, userContext) { + static async isSignUpAllowed(tenantId, newUser, isVerified, userContext) { return await recipe_1.default.getInstance().isSignUpAllowed({ newUser, isVerified, @@ -106,7 +105,7 @@ class Wrapper { userContext, }); } - static async isSignInAllowed(recipeUserId, tenantId, userContext = {}) { + static async isSignInAllowed(tenantId, recipeUserId, userContext = {}) { const user = await __1.getUser(recipeUserId.getAsString(), userContext); if (user === undefined) { // Should never really come here unless a programming error happened in the app @@ -118,7 +117,7 @@ class Wrapper { userContext, }); } - static async isEmailChangeAllowed(recipeUserId, newEmail, isVerified, tenantId, userContext) { + static async isEmailChangeAllowed(tenantId, recipeUserId, newEmail, isVerified, userContext) { const user = await __1.getUser(recipeUserId.getAsString(), userContext); return await recipe_1.default.getInstance().isEmailChangeAllowed({ user, diff --git a/lib/build/recipe/accountlinking/recipe.d.ts b/lib/build/recipe/accountlinking/recipe.d.ts index 90c7289ea..c94caf9cb 100644 --- a/lib/build/recipe/accountlinking/recipe.d.ts +++ b/lib/build/recipe/accountlinking/recipe.d.ts @@ -90,7 +90,6 @@ export default class Recipe extends RecipeModule { userContext: any; }) => Promise; verifyEmailForRecipeUserIfLinkedAccountsAreVerified: (input: { - tenantId: string; user: User; recipeUserId: RecipeUserId; userContext: any; diff --git a/lib/build/recipe/accountlinking/recipe.js b/lib/build/recipe/accountlinking/recipe.js index a4d692095..bfb6e8260 100644 --- a/lib/build/recipe/accountlinking/recipe.js +++ b/lib/build/recipe/accountlinking/recipe.js @@ -106,7 +106,6 @@ class Recipe extends recipeModule_1.default { return user; } let linkAccountsResult = await this.recipeInterfaceImpl.linkAccounts({ - tenantId, recipeUserId: user.loginMethods[0].recipeUserId, primaryUserId: primaryUser.id, userContext, @@ -560,7 +559,10 @@ class Recipe extends recipeModule_1.default { let resp = await recipe_1.default .getInstanceOrThrowError() .recipeInterfaceImpl.createEmailVerificationToken({ - tenantId: input.tenantId, + // While the token we create here is tenant specific, the verification status is not + // So we can use any tenantId the user is associated with here as long as we use the + // same in the verifyEmailUsingToken call + tenantId: input.user.tenantIds[0], recipeUserId: input.recipeUserId, email: recipeUserEmail, userContext: input.userContext, @@ -569,7 +571,8 @@ class Recipe extends recipeModule_1.default { // we purposely pass in false below cause we don't want account // linking to happen await recipe_1.default.getInstanceOrThrowError().recipeInterfaceImpl.verifyEmailUsingToken({ - tenantId: input.tenantId, + // See comment about tenantId in the createEmailVerificationToken params + tenantId: input.user.tenantIds[0], token: resp.token, attemptAccountLinking: false, userContext: input.userContext, diff --git a/lib/build/recipe/accountlinking/recipeImplementation.js b/lib/build/recipe/accountlinking/recipeImplementation.js index b3d0fd8c7..2961aef3c 100644 --- a/lib/build/recipe/accountlinking/recipeImplementation.js +++ b/lib/build/recipe/accountlinking/recipeImplementation.js @@ -75,7 +75,7 @@ function getRecipeImplementation(querier, config, recipeInstance) { ); return result; }, - linkAccounts: async function ({ tenantId, recipeUserId, primaryUserId, userContext }) { + linkAccounts: async function ({ recipeUserId, primaryUserId, userContext }) { const accountsLinkingResult = await querier.sendPostRequest( new normalisedURLPath_1.default("/recipe/accountlinking/user/link"), { @@ -94,7 +94,6 @@ function getRecipeImplementation(querier, config, recipeInstance) { let user = accountsLinkingResult.user; if (!accountsLinkingResult.accountsAlreadyLinked) { await recipeInstance.verifyEmailForRecipeUserIfLinkedAccountsAreVerified({ - tenantId, user: user, recipeUserId, userContext, @@ -113,7 +112,7 @@ function getRecipeImplementation(querier, config, recipeInstance) { if (loginMethodInfo === undefined) { throw Error("this error should never be thrown"); } - await config.onAccountLinked(user, loginMethodInfo, tenantId, userContext); + await config.onAccountLinked(user, loginMethodInfo, userContext); } accountsLinkingResult.user = user; } diff --git a/lib/build/recipe/accountlinking/types.d.ts b/lib/build/recipe/accountlinking/types.d.ts index c3bfe52c4..8c5baa735 100644 --- a/lib/build/recipe/accountlinking/types.d.ts +++ b/lib/build/recipe/accountlinking/types.d.ts @@ -3,12 +3,7 @@ import OverrideableBuilder from "supertokens-js-override"; import type { User } from "../../types"; import RecipeUserId from "../../recipeUserId"; export declare type TypeInput = { - onAccountLinked?: ( - user: User, - newAccountInfo: RecipeLevelUser, - tenantId: string, - userContext: any - ) => Promise; + onAccountLinked?: (user: User, newAccountInfo: RecipeLevelUser, userContext: any) => Promise; shouldDoAutomaticAccountLinking?: ( newAccountInfo: AccountInfoWithRecipeId, user: User | undefined, @@ -31,7 +26,7 @@ export declare type TypeInput = { }; }; export declare type TypeNormalisedInput = { - onAccountLinked: (user: User, newAccountInfo: RecipeLevelUser, tenantId: string, userContext: any) => Promise; + onAccountLinked: (user: User, newAccountInfo: RecipeLevelUser, userContext: any) => Promise; shouldDoAutomaticAccountLinking: ( newAccountInfo: AccountInfoWithRecipeId, user: User | undefined, @@ -126,7 +121,6 @@ export declare type RecipeInterface = { } >; linkAccounts: (input: { - tenantId: string; recipeUserId: RecipeUserId; primaryUserId: string; userContext: any; diff --git a/lib/build/recipe/emailpassword/recipeImplementation.js b/lib/build/recipe/emailpassword/recipeImplementation.js index c746e8cbb..f42372b28 100644 --- a/lib/build/recipe/emailpassword/recipeImplementation.js +++ b/lib/build/recipe/emailpassword/recipeImplementation.js @@ -71,7 +71,6 @@ function getRecipeInterface(querier, getEmailPasswordConfig) { ); if (!loginMethod.verified) { await recipe_1.default.getInstance().verifyEmailForRecipeUserIfLinkedAccountsAreVerified({ - tenantId, user: response.user, recipeUserId: response.recipeUserId, userContext, @@ -156,7 +155,6 @@ function getRecipeInterface(querier, getEmailPasswordConfig) { }; } await recipe_1.default.getInstance().verifyEmailForRecipeUserIfLinkedAccountsAreVerified({ - tenantId: input.tenantIdForPasswordPolicy, user, recipeUserId: input.recipeUserId, userContext: input.userContext, diff --git a/lib/build/recipe/passwordless/recipeImplementation.js b/lib/build/recipe/passwordless/recipeImplementation.js index aac7162cb..f715a7955 100644 --- a/lib/build/recipe/passwordless/recipeImplementation.js +++ b/lib/build/recipe/passwordless/recipeImplementation.js @@ -164,7 +164,6 @@ function getRecipeInterface(querier) { }; } await recipe_1.default.getInstance().verifyEmailForRecipeUserIfLinkedAccountsAreVerified({ - tenantId: input.tenantId, user, recipeUserId: input.recipeUserId, userContext: input.userContext, diff --git a/lib/build/recipe/thirdparty/recipeImplementation.js b/lib/build/recipe/thirdparty/recipeImplementation.js index 8b7fcaa19..5e861feb5 100644 --- a/lib/build/recipe/thirdparty/recipeImplementation.js +++ b/lib/build/recipe/thirdparty/recipeImplementation.js @@ -36,7 +36,6 @@ function getRecipeImplementation(querier, providers) { response.user = new user_1.User(response.user); response.recipeUserId = new recipeUserId_1.default(response.recipeUserId); await recipe_1.default.getInstance().verifyEmailForRecipeUserIfLinkedAccountsAreVerified({ - tenantId, user: response.user, recipeUserId: response.recipeUserId, userContext, diff --git a/lib/ts/recipe/accountlinking/index.ts b/lib/ts/recipe/accountlinking/index.ts index 58a26584b..c9e15f2da 100644 --- a/lib/ts/recipe/accountlinking/index.ts +++ b/lib/ts/recipe/accountlinking/index.ts @@ -31,8 +31,8 @@ export default class Wrapper { * no linking that happened. */ static async createPrimaryUserIdOrLinkAccounts( - recipeUserId: RecipeUserId, tenantId: string, + recipeUserId: RecipeUserId, userContext: any = {} ) { const user = await getUser(recipeUserId.getAsString(), userContext); @@ -96,14 +96,8 @@ export default class Wrapper { }); } - static async linkAccounts( - tenantId: string, - recipeUserId: RecipeUserId, - primaryUserId: string, - userContext: any = {} - ) { + static async linkAccounts(recipeUserId: RecipeUserId, primaryUserId: string, userContext: any = {}) { return await Recipe.getInstance().recipeInterfaceImpl.linkAccounts({ - tenantId, recipeUserId, primaryUserId, userContext, @@ -118,9 +112,9 @@ export default class Wrapper { } static async isSignUpAllowed( + tenantId: string, newUser: AccountInfoWithRecipeId, isVerified: boolean, - tenantId: string, userContext?: any ) { return await Recipe.getInstance().isSignUpAllowed({ @@ -131,7 +125,7 @@ export default class Wrapper { }); } - static async isSignInAllowed(recipeUserId: RecipeUserId, tenantId: string, userContext: any = {}) { + static async isSignInAllowed(tenantId: string, recipeUserId: RecipeUserId, userContext: any = {}) { const user = await getUser(recipeUserId.getAsString(), userContext); if (user === undefined) { // Should never really come here unless a programming error happened in the app @@ -146,10 +140,10 @@ export default class Wrapper { } static async isEmailChangeAllowed( + tenantId: string, recipeUserId: RecipeUserId, newEmail: string, isVerified: boolean, - tenantId: string, userContext?: any ) { const user = await getUser(recipeUserId.getAsString(), userContext); diff --git a/lib/ts/recipe/accountlinking/recipe.ts b/lib/ts/recipe/accountlinking/recipe.ts index a2c335f12..d11ff104a 100644 --- a/lib/ts/recipe/accountlinking/recipe.ts +++ b/lib/ts/recipe/accountlinking/recipe.ts @@ -225,7 +225,6 @@ export default class Recipe extends RecipeModule { } let linkAccountsResult = await this.recipeInterfaceImpl.linkAccounts({ - tenantId, recipeUserId: user.loginMethods[0].recipeUserId, primaryUserId: primaryUser.id, userContext, @@ -710,7 +709,6 @@ export default class Recipe extends RecipeModule { }; verifyEmailForRecipeUserIfLinkedAccountsAreVerified = async (input: { - tenantId: string; user: User; recipeUserId: RecipeUserId; userContext: any; @@ -754,7 +752,10 @@ export default class Recipe extends RecipeModule { if (shouldVerifyEmail) { let resp = await EmailVerificationRecipe.getInstanceOrThrowError().recipeInterfaceImpl.createEmailVerificationToken( { - tenantId: input.tenantId, + // While the token we create here is tenant specific, the verification status is not + // So we can use any tenantId the user is associated with here as long as we use the + // same in the verifyEmailUsingToken call + tenantId: input.user.tenantIds[0], recipeUserId: input.recipeUserId, email: recipeUserEmail, userContext: input.userContext, @@ -765,7 +766,8 @@ export default class Recipe extends RecipeModule { // linking to happen await EmailVerificationRecipe.getInstanceOrThrowError().recipeInterfaceImpl.verifyEmailUsingToken( { - tenantId: input.tenantId, + // See comment about tenantId in the createEmailVerificationToken params + tenantId: input.user.tenantIds[0], token: resp.token, attemptAccountLinking: false, userContext: input.userContext, diff --git a/lib/ts/recipe/accountlinking/recipeImplementation.ts b/lib/ts/recipe/accountlinking/recipeImplementation.ts index e4d7db7f1..1667c2647 100644 --- a/lib/ts/recipe/accountlinking/recipeImplementation.ts +++ b/lib/ts/recipe/accountlinking/recipeImplementation.ts @@ -159,12 +159,10 @@ export default function getRecipeImplementation( linkAccounts: async function ( this: RecipeInterface, { - tenantId, recipeUserId, primaryUserId, userContext, }: { - tenantId: string; recipeUserId: RecipeUserId; primaryUserId: string; userContext: any; @@ -208,7 +206,6 @@ export default function getRecipeImplementation( let user: UserType = accountsLinkingResult.user; if (!accountsLinkingResult.accountsAlreadyLinked) { await recipeInstance.verifyEmailForRecipeUserIfLinkedAccountsAreVerified({ - tenantId, user: user, recipeUserId, userContext, @@ -229,7 +226,7 @@ export default function getRecipeImplementation( throw Error("this error should never be thrown"); } - await config.onAccountLinked(user, loginMethodInfo, tenantId, userContext); + await config.onAccountLinked(user, loginMethodInfo, userContext); } accountsLinkingResult.user = user; } diff --git a/lib/ts/recipe/accountlinking/types.ts b/lib/ts/recipe/accountlinking/types.ts index ddaa5e49f..6d4bd9264 100644 --- a/lib/ts/recipe/accountlinking/types.ts +++ b/lib/ts/recipe/accountlinking/types.ts @@ -18,12 +18,7 @@ import type { User } from "../../types"; import RecipeUserId from "../../recipeUserId"; export type TypeInput = { - onAccountLinked?: ( - user: User, - newAccountInfo: RecipeLevelUser, - tenantId: string, - userContext: any - ) => Promise; + onAccountLinked?: (user: User, newAccountInfo: RecipeLevelUser, userContext: any) => Promise; shouldDoAutomaticAccountLinking?: ( newAccountInfo: AccountInfoWithRecipeId, user: User | undefined, @@ -47,7 +42,7 @@ export type TypeInput = { }; export type TypeNormalisedInput = { - onAccountLinked: (user: User, newAccountInfo: RecipeLevelUser, tenantId: string, userContext: any) => Promise; + onAccountLinked: (user: User, newAccountInfo: RecipeLevelUser, userContext: any) => Promise; shouldDoAutomaticAccountLinking: ( newAccountInfo: AccountInfoWithRecipeId, user: User | undefined, @@ -141,7 +136,6 @@ export type RecipeInterface = { } >; linkAccounts: (input: { - tenantId: string; recipeUserId: RecipeUserId; primaryUserId: string; userContext: any; diff --git a/lib/ts/recipe/emailpassword/recipeImplementation.ts b/lib/ts/recipe/emailpassword/recipeImplementation.ts index 479c2c215..3b4bdaf3c 100644 --- a/lib/ts/recipe/emailpassword/recipeImplementation.ts +++ b/lib/ts/recipe/emailpassword/recipeImplementation.ts @@ -116,7 +116,6 @@ export default function getRecipeInterface( if (!loginMethod.verified) { await AccountLinking.getInstance().verifyEmailForRecipeUserIfLinkedAccountsAreVerified({ - tenantId, user: response.user, recipeUserId: response.recipeUserId, userContext, @@ -243,7 +242,6 @@ export default function getRecipeInterface( }; } await AccountLinking.getInstance().verifyEmailForRecipeUserIfLinkedAccountsAreVerified({ - tenantId: input.tenantIdForPasswordPolicy, user, recipeUserId: input.recipeUserId, userContext: input.userContext, diff --git a/lib/ts/recipe/passwordless/recipeImplementation.ts b/lib/ts/recipe/passwordless/recipeImplementation.ts index 54af90100..3c951a74c 100644 --- a/lib/ts/recipe/passwordless/recipeImplementation.ts +++ b/lib/ts/recipe/passwordless/recipeImplementation.ts @@ -170,7 +170,6 @@ export default function getRecipeInterface(querier: Querier): RecipeInterface { }; } await AccountLinking.getInstance().verifyEmailForRecipeUserIfLinkedAccountsAreVerified({ - tenantId: input.tenantId, user, recipeUserId: input.recipeUserId, userContext: input.userContext, diff --git a/lib/ts/recipe/thirdparty/recipeImplementation.ts b/lib/ts/recipe/thirdparty/recipeImplementation.ts index d5ed89e96..72fcfac01 100644 --- a/lib/ts/recipe/thirdparty/recipeImplementation.ts +++ b/lib/ts/recipe/thirdparty/recipeImplementation.ts @@ -52,7 +52,6 @@ export default function getRecipeImplementation(querier: Querier, providers: Pro response.recipeUserId = new RecipeUserId(response.recipeUserId); await AccountLinking.getInstance().verifyEmailForRecipeUserIfLinkedAccountsAreVerified({ - tenantId, user: response.user, recipeUserId: response.recipeUserId, userContext, diff --git a/test/accountlinking/emailpassword.test.js b/test/accountlinking/emailpassword.test.js index 619630ed7..dbd34b985 100644 --- a/test/accountlinking/emailpassword.test.js +++ b/test/accountlinking/emailpassword.test.js @@ -449,7 +449,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpassword.t assert(!user.isPrimaryUser); assert(user.loginMethods[0].verified === false); - await AccountLinking.linkAccounts("public", user.loginMethods[0].recipeUserId, tpUser.id); + await AccountLinking.linkAccounts(user.loginMethods[0].recipeUserId, tpUser.id); user = (await EmailPassword.signIn("public", "test@example.com", "password123")).user; assert(user.isPrimaryUser === true); @@ -491,7 +491,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpassword.t const email2 = `test+${Date.now()}@example.com`; let user2 = (await EmailPassword.signUp("public", email2, "password123", { doNotLink: true })).user; - const linkResp = await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + const linkResp = await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); assert.strictEqual(linkResp.status, "OK"); const primUser = linkResp.user; @@ -575,10 +575,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpassword.t assert(response.status === "OK"); let isAllowed = await AccountLinking.isEmailChangeAllowed( + "public", response.user.loginMethods[0].recipeUserId, "test@example.com", - false, - "public" + false ); assert(isAllowed === false); @@ -649,10 +649,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpassword.t let recipeUserId = response.user.loginMethods[0].recipeUserId; let isAllowed = await AccountLinking.isEmailChangeAllowed( + "public", response.user.loginMethods[0].recipeUserId, "test@example.com", - false, - "public" + false ); assert(isAllowed === true); @@ -723,13 +723,13 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpassword.t let response = await EmailPassword.signUp("public", "test2@example.com", "password123"); assert(response.status === "OK"); let recipeUserId = response.user.loginMethods[0].recipeUserId; - await AccountLinking.linkAccounts("public", recipeUserId, user.id); + await AccountLinking.linkAccounts(recipeUserId, user.id); let isAllowed = await AccountLinking.isEmailChangeAllowed( + "public", recipeUserId, "test@example.com", - false, - "public" + false ); assert(isAllowed === true); diff --git a/test/accountlinking/emailpasswordapis.test.js b/test/accountlinking/emailpasswordapis.test.js index e7aa46e4d..8533b1c1f 100644 --- a/test/accountlinking/emailpasswordapis.test.js +++ b/test/accountlinking/emailpasswordapis.test.js @@ -2388,7 +2388,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpasswordap let epUser = await EmailPassword.signUp("public", "test@example.com", "password1234", { doNotLink: true, }); - await AccountLinking.linkAccounts("public", epUser.user.loginMethods[0].recipeUserId, tpUser.user.id); + await AccountLinking.linkAccounts(epUser.user.loginMethods[0].recipeUserId, tpUser.user.id); let res = await new Promise((resolve) => request(app) diff --git a/test/accountlinking/emailpasswordapis2.test.js b/test/accountlinking/emailpasswordapis2.test.js index 41a1d7b3c..2cad4779a 100644 --- a/test/accountlinking/emailpasswordapis2.test.js +++ b/test/accountlinking/emailpasswordapis2.test.js @@ -682,7 +682,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpasswordap await AccountLinking.createPrimaryUser(supertokens.convertToRecipeUserId(tpUser.id)); let epUser = await EmailPassword.signUp("public", "test@example.com", "password1234"); - await AccountLinking.linkAccounts("public", epUser.user.loginMethods[0].recipeUserId, tpUser.id); + await AccountLinking.linkAccounts(epUser.user.loginMethods[0].recipeUserId, tpUser.id); let res = await new Promise((resolve) => request(app) @@ -780,7 +780,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpasswordap await AccountLinking.createPrimaryUser(supertokens.convertToRecipeUserId(tpUser.id)); let epUser = await EmailPassword.signUp("public", "test@example.com", "password1234"); - await AccountLinking.linkAccounts("public", epUser.user.loginMethods[0].recipeUserId, tpUser.id); + await AccountLinking.linkAccounts(epUser.user.loginMethods[0].recipeUserId, tpUser.id); let res = await new Promise((resolve) => request(app) @@ -1669,7 +1669,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpasswordap doNotLink: true, }); assert(epUser2.user.isPrimaryUser === false); - await AccountLinking.linkAccounts("public", epUser2.user.loginMethods[0].recipeUserId, tpUser.id); + await AccountLinking.linkAccounts(epUser2.user.loginMethods[0].recipeUserId, tpUser.id); let epUser = await EmailPassword.signUp("public", "test@example.com", "password1234", { doNotLink: true, @@ -1784,7 +1784,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpasswordap doNotLink: true, }); assert(epUser2.user.isPrimaryUser === false); - await AccountLinking.linkAccounts("public", epUser2.user.loginMethods[0].recipeUserId, tpUser.id); + await AccountLinking.linkAccounts(epUser2.user.loginMethods[0].recipeUserId, tpUser.id); let token = await EmailVerification.createEmailVerificationToken( "public", supertokens.convertToRecipeUserId(epUser2.user.id) @@ -1912,7 +1912,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpasswordap false ); assert(tpUser2.user.isPrimaryUser === false); - await AccountLinking.linkAccounts("public", supertokens.convertToRecipeUserId(tpUser2.user.id), tpUser.id); + await AccountLinking.linkAccounts(supertokens.convertToRecipeUserId(tpUser2.user.id), tpUser.id); let epUser = await EmailPassword.signUp("public", "test@example.com", "password1234", { doNotLink: true, @@ -3100,7 +3100,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpasswordap await AccountLinking.createPrimaryUser(supertokens.convertToRecipeUserId(tpUser.id)); let epUser = await EmailPassword.signUp("public", "test@example.com", "password1234"); - await AccountLinking.linkAccounts("public", epUser.user.loginMethods[0].recipeUserId, tpUser.id); + await AccountLinking.linkAccounts(epUser.user.loginMethods[0].recipeUserId, tpUser.id); let res = await new Promise((resolve) => request(app) @@ -3261,7 +3261,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpasswordap await AccountLinking.createPrimaryUser(supertokens.convertToRecipeUserId(tpUser.id)); let epUser = await EmailPassword.signUp("public", "test@example.com", "password1234"); - await AccountLinking.linkAccounts("public", epUser.user.loginMethods[0].recipeUserId, tpUser.id); + await AccountLinking.linkAccounts(epUser.user.loginMethods[0].recipeUserId, tpUser.id); let res = await new Promise((resolve) => request(app) @@ -3423,10 +3423,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpasswordap await AccountLinking.createPrimaryUser(supertokens.convertToRecipeUserId(tpUser.id)); let epUser = await EmailPassword.signUp("public", "test@example.com", "password1234"); - await AccountLinking.linkAccounts("public", epUser.user.loginMethods[0].recipeUserId, tpUser.id); + await AccountLinking.linkAccounts(epUser.user.loginMethods[0].recipeUserId, tpUser.id); let epUser2 = await EmailPassword.signUp("public", "test2@example.com", "password1234"); - await AccountLinking.linkAccounts("public", epUser2.user.loginMethods[0].recipeUserId, tpUser.id); + await AccountLinking.linkAccounts(epUser2.user.loginMethods[0].recipeUserId, tpUser.id); let pUser = await supertokens.getUser(epUser.user.id); assert(pUser.loginMethods.length === 3); @@ -3601,7 +3601,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpasswordap await AccountLinking.createPrimaryUser(supertokens.convertToRecipeUserId(tpUser.id)); let epUser = await EmailPassword.signUp("public", "test@example.com", "password1234"); - await AccountLinking.linkAccounts("public", epUser.user.loginMethods[0].recipeUserId, tpUser.id); + await AccountLinking.linkAccounts(epUser.user.loginMethods[0].recipeUserId, tpUser.id); let res = await new Promise((resolve) => request(app) @@ -3764,11 +3764,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpasswordap await ThirdParty.manuallyCreateOrUpdateUser("public", "google", "abcd2" + date, email, false) ).user; - const linkRes = await AccountLinking.linkAccounts( - "public", - tpUserUnverified.loginMethods[0].recipeUserId, - tpUser.id - ); + const linkRes = await AccountLinking.linkAccounts(tpUserUnverified.loginMethods[0].recipeUserId, tpUser.id); assert.strictEqual(linkRes.status, "OK"); @@ -3935,11 +3931,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpasswordap await ThirdParty.manuallyCreateOrUpdateUser("public", "google", "abcd2" + date, email, false) ).user; - const linkRes = await AccountLinking.linkAccounts( - "public", - tpUserUnverified.loginMethods[0].recipeUserId, - epUser.id - ); + const linkRes = await AccountLinking.linkAccounts(tpUserUnverified.loginMethods[0].recipeUserId, epUser.id); assert.strictEqual(linkRes.status, "OK"); @@ -4099,11 +4091,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpasswordap await ThirdParty.manuallyCreateOrUpdateUser("public", "google", "abcd2" + date, email, true) ).user; - const linkRes = await AccountLinking.linkAccounts( - "public", - tpUserUnverified.loginMethods[0].recipeUserId, - epUser.id - ); + const linkRes = await AccountLinking.linkAccounts(tpUserUnverified.loginMethods[0].recipeUserId, epUser.id); assert.strictEqual(linkRes.status, "OK"); @@ -4261,7 +4249,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/emailpasswordap let tpUser = (await ThirdParty.manuallyCreateOrUpdateUser("public", "google", "abcd2" + date, email, true)) .user; - const linkRes = await AccountLinking.linkAccounts("public", tpUser.loginMethods[0].recipeUserId, epUser.id); + const linkRes = await AccountLinking.linkAccounts(tpUser.loginMethods[0].recipeUserId, epUser.id); assert.strictEqual(linkRes.status, "OK"); const deleteResp = await supertokens.deleteUser(epUser.id, false); diff --git a/test/accountlinking/emailverification.test.js b/test/accountlinking/emailverification.test.js index 93542dd3b..99c2f897c 100644 --- a/test/accountlinking/emailverification.test.js +++ b/test/accountlinking/emailverification.test.js @@ -614,7 +614,7 @@ describe(`emailverificationTests: ${printPath("[test/accountlinking/emailverific let epUser = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; assert(epUser.isPrimaryUser === false); - await AccountLinking.linkAccounts("public", epUser.loginMethods[0].recipeUserId, tpUser.user.id); + await AccountLinking.linkAccounts(epUser.loginMethods[0].recipeUserId, tpUser.user.id); epUser = await supertokens.getUser(epUser.id); assert(epUser.isPrimaryUser === true); diff --git a/test/accountlinking/emailverificationapis.test.js b/test/accountlinking/emailverificationapis.test.js index 85c9f5950..473cc9867 100644 --- a/test/accountlinking/emailverificationapis.test.js +++ b/test/accountlinking/emailverificationapis.test.js @@ -352,7 +352,7 @@ describe(`emailverificationapiTests: ${printPath("[test/accountlinking/emailveri ); assert(tpUser.user.isPrimaryUser === false); await AccountLinking.createPrimaryUser(supertokens.convertToRecipeUserId(tpUser.user.id)); - await AccountLinking.linkAccounts("public", epUser.loginMethods[0].recipeUserId, tpUser.user.id); + await AccountLinking.linkAccounts(epUser.loginMethods[0].recipeUserId, tpUser.user.id); const app = express(); @@ -1398,7 +1398,7 @@ describe(`emailverificationapiTests: ${printPath("[test/accountlinking/emailveri await AccountLinking.createPrimaryUser(epUser.user.loginMethods[0].recipeUserId); let epUser2 = await EmailPassword.signUp("public", "random2@example.com", "password1234"); - await AccountLinking.linkAccounts("public", epUser2.user.loginMethods[0].recipeUserId, epUser.user.id); + await AccountLinking.linkAccounts(epUser2.user.loginMethods[0].recipeUserId, epUser.user.id); let pUser = await supertokens.getUser(epUser.user.id); assert(pUser.isPrimaryUser === true); diff --git a/test/accountlinking/helperFunctions.test.js b/test/accountlinking/helperFunctions.test.js index fb8d5944a..a0ae54dc2 100644 --- a/test/accountlinking/helperFunctions.test.js +++ b/test/accountlinking/helperFunctions.test.js @@ -71,10 +71,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions assert(user.isPrimaryUser === true); assert(user.loginMethods[0].verified === true); - let response = await AccountLinking.createPrimaryUserIdOrLinkAccounts({ - recipeUserId: user.loginMethods[0].recipeUserId, - checkAccountsToLinkTableAsWell: true, - }); + let response = await AccountLinking.createPrimaryUserIdOrLinkAccounts( + "public", + user.loginMethods[0].recipeUserId + ); assert(response === user.id); }); @@ -127,10 +127,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions user = await supertokens.getUser(user.id); assert(user.isPrimaryUser === false); - let response = await AccountLinking.createPrimaryUserIdOrLinkAccounts({ - recipeUserId: user.loginMethods[0].recipeUserId, - checkAccountsToLinkTableAsWell: true, - }); + let response = await AccountLinking.createPrimaryUserIdOrLinkAccounts( + "public", + user.loginMethods[0].recipeUserId + ); assert(response === user.id); let userObj = await supertokens.getUser(user.id); @@ -181,10 +181,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions assert(user.isPrimaryUser === false); - let response = await AccountLinking.createPrimaryUserIdOrLinkAccounts({ - recipeUserId: user.loginMethods[0].recipeUserId, - checkAccountsToLinkTableAsWell: true, - }); + let response = await AccountLinking.createPrimaryUserIdOrLinkAccounts( + "public", + user.loginMethods[0].recipeUserId + ); assert(response === user.id); let userObj = await supertokens.getUser(user.id); @@ -227,10 +227,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions assert(user.isPrimaryUser === false); assert(user.loginMethods[0].verified === false); - let response = await AccountLinking.createPrimaryUserIdOrLinkAccounts({ - recipeUserId: user.loginMethods[0].recipeUserId, - checkAccountsToLinkTableAsWell: true, - }); + let response = await AccountLinking.createPrimaryUserIdOrLinkAccounts( + "public", + user.loginMethods[0].recipeUserId + ); assert(response === user.id); let userObj = await supertokens.getUser(user.id); @@ -315,10 +315,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions assert(user.isPrimaryUser === false); assert(user.loginMethods[0].verified === true); - let response = await AccountLinking.createPrimaryUserIdOrLinkAccounts({ - recipeUserId: user.loginMethods[0].recipeUserId, - checkAccountsToLinkTableAsWell: true, - }); + let response = await AccountLinking.createPrimaryUserIdOrLinkAccounts( + "public", + user.loginMethods[0].recipeUserId + ); assert(response === primaryUser.id); let userObj = await supertokens.getUser(primaryUser.id); @@ -395,10 +395,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions assert(user.isPrimaryUser === false); assert(user.loginMethods[0].verified === true); - let response = await AccountLinking.createPrimaryUserIdOrLinkAccounts({ - recipeUserId: user.loginMethods[0].recipeUserId, - checkAccountsToLinkTableAsWell: true, - }); + let response = await AccountLinking.createPrimaryUserIdOrLinkAccounts( + "public", + user.loginMethods[0].recipeUserId + ); assert(response === user.id); let userObj = await supertokens.getUser(user.id); @@ -471,10 +471,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions assert(user.isPrimaryUser === false); assert(user.loginMethods[0].verified === false); - let response = await AccountLinking.createPrimaryUserIdOrLinkAccounts({ - recipeUserId: user.loginMethods[0].recipeUserId, - checkAccountsToLinkTableAsWell: true, - }); + let response = await AccountLinking.createPrimaryUserIdOrLinkAccounts( + "public", + user.loginMethods[0].recipeUserId + ); assert(response === user.id); let userObj = await supertokens.getUser(user.id); @@ -618,11 +618,11 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions }); let isAllowed = await AccountLinking.isSignUpAllowed( + "public", { email: "test@example.com", }, - true, - "public" + true ); assert(isAllowed); @@ -644,12 +644,12 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions try { await AccountLinking.isSignUpAllowed( + "public", { phoneNumber: "", email: "test@example.com", }, - true, - "public" + true ); assert(false); } catch (err) { @@ -692,11 +692,11 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions }); let isAllowed = await AccountLinking.isSignUpAllowed( + "public", { email: "test@example.com", }, - false, - "public" + false ); assert(isAllowed); @@ -731,11 +731,11 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions }); let isAllowed = await AccountLinking.isSignUpAllowed( + "public", { email: "test@example.com", }, - false, - "public" + false ); assert(isAllowed); @@ -776,11 +776,11 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions }); let isAllowed = await AccountLinking.isSignUpAllowed( + "public", { email: "test@example.com", }, - false, - "public" + false ); assert(isAllowed); @@ -821,11 +821,11 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions }); let isAllowed = await AccountLinking.isSignUpAllowed( + "public", { email: "test@example.com", }, - false, - "public" + false ); assert(!isAllowed); @@ -913,11 +913,11 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions assert(!tpUser.user.isPrimaryUser); let isAllowed = await AccountLinking.isSignUpAllowed( + "public", { email: "test@example.com", }, - false, - "public" + false ); assert(!isAllowed); @@ -959,11 +959,11 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions assert(pUser.isPrimaryUser); let isAllowed = await AccountLinking.isSignUpAllowed( + "public", { email: "test@example.com", }, - false, - "public" + false ); assert(!isAllowed); @@ -999,11 +999,11 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions assert(pUser.isPrimaryUser); let isAllowed = await AccountLinking.isSignUpAllowed( + "public", { email: "test@example.com", }, - false, - "public" + false ); assert(isAllowed); @@ -1049,11 +1049,11 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions await EmailVerification.verifyEmailUsingToken("public", token.token); let isAllowed = await AccountLinking.isSignUpAllowed( + "public", { email: "test@example.com", }, - true, - "public" + true ); assert(isAllowed); @@ -1118,11 +1118,11 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions await ThirdParty.manuallyCreateOrUpdateUser("public", "abcd", "abcd", "test@example.com", false); let isAllowed = await AccountLinking.isSignUpAllowed( + "public", { email: "test@example.com", }, - true, - "public" + true ); assert(isAllowed); @@ -1294,7 +1294,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions assert(response.status === "OK"); let recipeUserId = response.user.loginMethods[0].recipeUserId; - response = await AccountLinking.isEmailChangeAllowed(recipeUserId, "test@example.com", false, "public"); + response = await AccountLinking.isEmailChangeAllowed("public", recipeUserId, "test@example.com", false); assert(response === false); }); @@ -1366,10 +1366,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions let recipeUserId = response.user.loginMethods[0].recipeUserId; let isAllowed = await AccountLinking.isEmailChangeAllowed( + "public", response.user.loginMethods[0].recipeUserId, "test@example.com", - false, - "public" + false ); assert(isAllowed === true); @@ -1433,10 +1433,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions await AccountLinking.createPrimaryUser(response.user.loginMethods[0].recipeUserId); response = await AccountLinking.isEmailChangeAllowed( + "public", response.user.loginMethods[0].recipeUserId, "test@example.com", - false, - "public" + false ); assert(response === false); @@ -1491,10 +1491,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions await AccountLinking.createPrimaryUser(response.user.loginMethods[0].recipeUserId); response = await AccountLinking.isEmailChangeAllowed( + "public", response.user.loginMethods[0].recipeUserId, "test@example.com", - false, - "public" + false ); assert(response === true); @@ -1558,10 +1558,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions assert(response.user.isPrimaryUser === true); response = await AccountLinking.isEmailChangeAllowed( + "public", response.user.loginMethods[0].recipeUserId, "test@example.com", - false, - "public" + false ); assert(response === false); @@ -1616,10 +1616,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions await AccountLinking.createPrimaryUser(response.user.loginMethods[0].recipeUserId); response = await AccountLinking.isEmailChangeAllowed( + "public", response.user.loginMethods[0].recipeUserId, "test@example.com", - false, - "public" + false ); assert(response === true); @@ -1688,10 +1688,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions assert(response.user.isPrimaryUser === true); response = await AccountLinking.isEmailChangeAllowed( + "public", response.user.loginMethods[0].recipeUserId, "test@example.com", false, - "public", { doNotLink: true, } @@ -1754,10 +1754,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions assert(response.user.isPrimaryUser === true); response = await AccountLinking.isEmailChangeAllowed( + "public", response.user.loginMethods[0].recipeUserId, "test@example.com", false, - "public", { doNotLink: true, } @@ -1826,10 +1826,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions let recipeUserId = response.user.loginMethods[0].recipeUserId; response = await AccountLinking.isEmailChangeAllowed( + "public", response.user.loginMethods[0].recipeUserId, "test@example.com", - true, - "public" + true ); assert(response === true); @@ -1895,10 +1895,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions let recipeUserId = response.user.loginMethods[0].recipeUserId; response = await AccountLinking.isEmailChangeAllowed( + "public", response.user.loginMethods[0].recipeUserId, "test@example.com", - false, - "public" + false ); assert(response === true); @@ -1969,10 +1969,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions let recipeUserId = response.user.loginMethods[0].recipeUserId; response = await AccountLinking.isEmailChangeAllowed( + "public", response.user.loginMethods[0].recipeUserId, "test@example.com", false, - "public", { doNotLink: true, } @@ -2047,10 +2047,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions let recipeUserId = response.user.loginMethods[0].recipeUserId; response = await AccountLinking.isEmailChangeAllowed( + "public", response.user.loginMethods[0].recipeUserId, "test@example.com", false, - "public", { doNotLink: true, } @@ -2110,10 +2110,10 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions let recipeUserId = response.user.loginMethods[0].recipeUserId; response = await AccountLinking.isEmailChangeAllowed( + "public", response.user.loginMethods[0].recipeUserId, "test2@example.com", - false, - "public" + false ); assert(response === true); @@ -2137,7 +2137,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions let user = await EmailPassword.signUp("public", "test@example.com", "abcd1234"); - let isAllowed = await AccountLinking.isSignInAllowed(user.user.loginMethods[0].recipeUserId, "public"); + let isAllowed = await AccountLinking.isSignInAllowed("public", user.user.loginMethods[0].recipeUserId); assert(isAllowed); }); @@ -2176,7 +2176,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions doNotLink: true, }); - let isAllowed = await AccountLinking.isSignInAllowed(user.user.loginMethods[0].recipeUserId, "public"); + let isAllowed = await AccountLinking.isSignInAllowed("public", user.user.loginMethods[0].recipeUserId); assert(isAllowed); }); @@ -2209,7 +2209,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions doNotLink: true, }); - let isAllowed = await AccountLinking.isSignInAllowed(user.user.loginMethods[0].recipeUserId, "public"); + let isAllowed = await AccountLinking.isSignInAllowed("public", user.user.loginMethods[0].recipeUserId); assert(isAllowed); }); @@ -2248,7 +2248,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions doNotLink: true, }); - let isAllowed = await AccountLinking.isSignInAllowed(user.user.loginMethods[0].recipeUserId, "public"); + let isAllowed = await AccountLinking.isSignInAllowed("public", user.user.loginMethods[0].recipeUserId); assert(isAllowed); }); @@ -2287,7 +2287,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions doNotLink: true, }); - let isAllowed = await AccountLinking.isSignInAllowed(user.user.loginMethods[0].recipeUserId, "public"); + let isAllowed = await AccountLinking.isSignInAllowed("public", user.user.loginMethods[0].recipeUserId); assert(!isAllowed); assert( @@ -2373,7 +2373,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions ); assert(!tpUser.user.isPrimaryUser); - let isAllowed = await AccountLinking.isSignInAllowed(tpUser.user.loginMethods[0].recipeUserId, "public"); + let isAllowed = await AccountLinking.isSignInAllowed("public", tpUser.user.loginMethods[0].recipeUserId); assert(!isAllowed); assert( @@ -2430,7 +2430,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions pUser = await supertokens.getUser(pUser.id); assert(pUser.isPrimaryUser); - let isAllowed = await AccountLinking.isSignInAllowed(pUser.loginMethods[0].recipeUserId, "public"); + let isAllowed = await AccountLinking.isSignInAllowed("public", pUser.loginMethods[0].recipeUserId); assert(isAllowed); @@ -2439,7 +2439,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions ).user; assert(tpUser.isPrimaryUser === false); - isAllowed = await AccountLinking.isSignInAllowed(tpUser.loginMethods[0].recipeUserId, "public"); + isAllowed = await AccountLinking.isSignInAllowed("public", tpUser.loginMethods[0].recipeUserId); assert(!isAllowed); }); @@ -2490,7 +2490,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions pUser = await supertokens.getUser(pUser.id); assert(pUser.isPrimaryUser); - let isAllowed = await AccountLinking.isSignInAllowed(pUser.loginMethods[0].recipeUserId, "public"); + let isAllowed = await AccountLinking.isSignInAllowed("public", pUser.loginMethods[0].recipeUserId); assert(isAllowed); @@ -2499,7 +2499,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions ).user; assert(tpUser.isPrimaryUser === false); - isAllowed = await AccountLinking.isSignInAllowed(tpUser.loginMethods[0].recipeUserId, "public"); + isAllowed = await AccountLinking.isSignInAllowed("public", tpUser.loginMethods[0].recipeUserId); assert(isAllowed); }); @@ -2573,7 +2573,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions assert(tpUser.isPrimaryUser === false); assert(tpUser.loginMethods[0].verified); - isAllowed = await AccountLinking.isSignInAllowed(tpUser.loginMethods[0].recipeUserId, "public"); + isAllowed = await AccountLinking.isSignInAllowed("public", tpUser.loginMethods[0].recipeUserId); assert(isAllowed); }); @@ -2644,7 +2644,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions true ); - let isAllowed = await AccountLinking.isSignInAllowed(user2.user.loginMethods[0].recipeUserId, "public"); + let isAllowed = await AccountLinking.isSignInAllowed("public", user2.user.loginMethods[0].recipeUserId); assert(isAllowed); }); @@ -2696,7 +2696,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions pUser = await supertokens.getUser(pUser.id); assert(pUser.isPrimaryUser); - let isAllowed = await AccountLinking.isSignInAllowed(pUser.loginMethods[0].recipeUserId, "public"); + let isAllowed = await AccountLinking.isSignInAllowed("public", pUser.loginMethods[0].recipeUserId); assert(isAllowed); @@ -2737,7 +2737,6 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions }); await AccountLinkingRecipe.getInstance().verifyEmailForRecipeUserIfLinkedAccountsAreVerified({ - tenantId: "public", recipeUserId: user.user.loginMethods[0].recipeUserId, }); }); @@ -2802,10 +2801,9 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions "test@example.com", false ); - await AccountLinking.linkAccounts("public", tpUser.user.loginMethods[0].recipeUserId, user.user.id); + await AccountLinking.linkAccounts(tpUser.user.loginMethods[0].recipeUserId, user.user.id); await AccountLinkingRecipe.getInstance().verifyEmailForRecipeUserIfLinkedAccountsAreVerified({ - tenantId: "public", recipeUserId: tpUser.user.loginMethods[0].recipeUserId, }); @@ -2877,10 +2875,9 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions "test2@example.com", false ); - await AccountLinking.linkAccounts("public", tpUser.user.loginMethods[0].recipeUserId, user.user.id); + await AccountLinking.linkAccounts(tpUser.user.loginMethods[0].recipeUserId, user.user.id); await AccountLinkingRecipe.getInstance().verifyEmailForRecipeUserIfLinkedAccountsAreVerified({ - tenantId: "public", recipeUserId: tpUser.user.loginMethods[0].recipeUserId, }); @@ -2947,10 +2944,9 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions "test2@example.com", false ); - await AccountLinking.linkAccounts("public", tpUser.user.loginMethods[0].recipeUserId, user.user.id); + await AccountLinking.linkAccounts(tpUser.user.loginMethods[0].recipeUserId, user.user.id); await AccountLinkingRecipe.getInstance().verifyEmailForRecipeUserIfLinkedAccountsAreVerified({ - tenantId: "public", recipeUserId: tpUser.user.loginMethods[0].recipeUserId, }); @@ -3016,7 +3012,6 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/helperFunctions ); await AccountLinkingRecipe.getInstance().verifyEmailForRecipeUserIfLinkedAccountsAreVerified({ - tenantId: "public", recipeUserId: tpUser.user.loginMethods[0].recipeUserId, }); diff --git a/test/accountlinking/multitenancy.test.js b/test/accountlinking/multitenancy.test.js index f2af82caf..55f2a2024 100644 --- a/test/accountlinking/multitenancy.test.js +++ b/test/accountlinking/multitenancy.test.js @@ -449,7 +449,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/multitenancy.te assert(!user.isPrimaryUser); assert(user.loginMethods[0].verified === false); - await AccountLinking.linkAccounts("public", user.loginMethods[0].recipeUserId, tpUser.id); + await AccountLinking.linkAccounts(user.loginMethods[0].recipeUserId, tpUser.id); user = (await EmailPassword.signIn("public", "test@example.com", "password123")).user; assert(user.isPrimaryUser === true); @@ -659,7 +659,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/multitenancy.te let response = await EmailPassword.signUp("public", "test2@example.com", "password123"); assert(response.status === "OK"); let recipeUserId = response.user.loginMethods[0].recipeUserId; - await AccountLinking.linkAccounts("public", recipeUserId, user.id); + await AccountLinking.linkAccounts(recipeUserId, user.id); let isAllowed = await AccountLinking.isEmailChangeAllowed(recipeUserId, "test@example.com"); assert(isAllowed === true); diff --git a/test/accountlinking/passwordlessapis.test.js b/test/accountlinking/passwordlessapis.test.js index d43ad1f3c..8c31094b0 100644 --- a/test/accountlinking/passwordlessapis.test.js +++ b/test/accountlinking/passwordlessapis.test.js @@ -855,7 +855,6 @@ async function getCreateCodeTestCase({ pwlessUser, otherRecipeUser, accountLinki assert.strictEqual(consumeResp.status, "OK"); if (pwlessUser.linked === true) { const linkResp = await AccountLinking.linkAccounts( - "public", consumeResp.user.loginMethods[0].recipeUserId, tpUser.user.id ); @@ -986,7 +985,6 @@ async function getConsumeCodeTestCase({ pwlessUser, otherRecipeUser, accountLink if (pwlessUser.linked === true) { if (tpUser) { const linkResp = await AccountLinking.linkAccounts( - "public", consumeResp.user.loginMethods[0].recipeUserId, tpUser.user.id ); diff --git a/test/accountlinking/recipeFunction.test.js b/test/accountlinking/recipeFunction.test.js index 2a1d5953e..4b1bbd6b2 100644 --- a/test/accountlinking/recipeFunction.test.js +++ b/test/accountlinking/recipeFunction.test.js @@ -121,7 +121,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. assert(user2.isPrimaryUser === false); await AccountLinking.createPrimaryUser(user.loginMethods[0].recipeUserId); - await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); let response = await AccountLinking.createPrimaryUser(user2.loginMethods[0].recipeUserId); assert(response.status === "RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR"); @@ -212,7 +212,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. let sessions = await Session.getAllSessionHandlesForUser(user2.loginMethods[0].recipeUserId.getAsString()); assert(sessions.length === 1); - let response = await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + let response = await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); assert(response.status === "OK"); assert(response.accountsAlreadyLinked === false); @@ -260,7 +260,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. assert(user2.isPrimaryUser === false); await AccountLinking.createPrimaryUser(user.loginMethods[0].recipeUserId); - let response = await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + let response = await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); assert(response.status === "OK"); assert(response.accountsAlreadyLinked === false); @@ -268,7 +268,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. let user3 = (await EmailPassword.signUp("public", "test3@example.com", "password123")).user; assert(user3.isPrimaryUser === false); - response = await AccountLinking.linkAccounts("public", user3.loginMethods[0].recipeUserId, user2.id); + response = await AccountLinking.linkAccounts(user3.loginMethods[0].recipeUserId, user2.id); assert(response.status === "OK"); assert(response.accountsAlreadyLinked === false); @@ -308,7 +308,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. assert(user2.isPrimaryUser === false); await AccountLinking.createPrimaryUser(user.loginMethods[0].recipeUserId); - const initialResp = await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + const initialResp = await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); assert.strictEqual(initialResp.status, "OK"); assert.notStrictEqual(initialResp.user, undefined); @@ -321,7 +321,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. let sessions = await Session.getAllSessionHandlesForUser(user2.loginMethods[0].recipeUserId.getAsString()); assert.strictEqual(sessions.length, 1); - let response = await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + let response = await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); assert.strictEqual(response.status, "OK"); assert(response.accountsAlreadyLinked); @@ -363,18 +363,14 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. assert(user2.isPrimaryUser === false); await AccountLinking.createPrimaryUser(user.loginMethods[0].recipeUserId); - await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); let otherPrimaryUser = (await EmailPassword.signUp("public", "test3@example.com", "password123")).user; await AccountLinking.createPrimaryUser(otherPrimaryUser.loginMethods[0].recipeUserId); primaryUserInCallback = undefined; - let response = await AccountLinking.linkAccounts( - "public", - user2.loginMethods[0].recipeUserId, - otherPrimaryUser.id - ); + let response = await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, otherPrimaryUser.id); assert(response.status === "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"); assert(response.primaryUserId === user.id); @@ -410,7 +406,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. let user2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; assert(user2.isPrimaryUser === false); - let resp = await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + let resp = await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); assert(resp.status === "INPUT_USER_IS_NOT_A_PRIMARY_USER"); }); @@ -459,7 +455,6 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. await AccountLinking.createPrimaryUser(otherPrimaryUser.loginMethods[0].recipeUserId); let response = await AccountLinking.linkAccounts( - "public", supertokens.convertToRecipeUserId(user2.id), otherPrimaryUser.id ); @@ -489,7 +484,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. await AccountLinking.createPrimaryUser(user.loginMethods[0].recipeUserId); - await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); // we create a new session to check that the session has not been revoked // when we link accounts, cause these users are already linked. @@ -574,7 +569,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. await AccountLinking.createPrimaryUser(user.loginMethods[0].recipeUserId); - await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); // we create a new session to check that the session has not been revoked // when we link accounts, cause these users are already linked. @@ -636,7 +631,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. let user2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; assert(user2.isPrimaryUser === false); - await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); { let primaryUser = await supertokens.getUser(user.id); assert(primaryUser !== undefined); @@ -689,7 +684,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. let user2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; assert(user2.isPrimaryUser === false); - await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); { let primaryUser = await supertokens.getUser(user.id); assert(primaryUser !== undefined); @@ -742,7 +737,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. let user2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; assert(user2.isPrimaryUser === false); - await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); { let primaryUser = await supertokens.getUser(user.id); assert(primaryUser !== undefined); @@ -813,7 +808,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. await AccountLinking.createPrimaryUser(supertokens.convertToRecipeUserId(user.id)); - let response = await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + let response = await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); assert(response.status === "OK"); assert(response.accountsAlreadyLinked === false); @@ -874,12 +869,12 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. await AccountLinking.createPrimaryUser(supertokens.convertToRecipeUserId(user.id)); - let response = await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + let response = await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); assert(response.status === "OK"); assert(response.accountsAlreadyLinked === false); - await AccountLinking.linkAccounts("public", user3.loginMethods[0].recipeUserId, user.id); + await AccountLinking.linkAccounts(user3.loginMethods[0].recipeUserId, user.id); { let isVerified = await EmailVerification.isEmailVerified(supertokens.convertToRecipeUserId(user.id)); @@ -942,7 +937,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. await AccountLinking.createPrimaryUser(supertokens.convertToRecipeUserId(user.id)); - let response = await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + let response = await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); assert(response.status === "OK"); assert(response.accountsAlreadyLinked === false); @@ -1001,7 +996,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/recipeFunction. await AccountLinking.createPrimaryUser(supertokens.convertToRecipeUserId(user.id)); - let response = await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + let response = await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); assert(response.status === "OK"); assert(response.accountsAlreadyLinked === false); diff --git a/test/accountlinking/session.test.js b/test/accountlinking/session.test.js index 927a73de5..c3dded2c1 100644 --- a/test/accountlinking/session.test.js +++ b/test/accountlinking/session.test.js @@ -91,7 +91,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -195,7 +195,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); const app = express(); @@ -325,7 +325,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -411,7 +411,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -532,7 +532,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -674,7 +674,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -762,7 +762,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -824,7 +824,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -868,7 +868,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -932,7 +932,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let epuser2session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -970,7 +970,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let epuser2session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -1008,7 +1008,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let epuser2session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -1048,7 +1048,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let epuser2session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -1085,7 +1085,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let epuser2session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -1122,7 +1122,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let epuser2session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -1314,7 +1314,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -1358,7 +1358,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -1421,7 +1421,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let session = await Session.createNewSessionWithoutRequestResponse( "public", @@ -1466,7 +1466,7 @@ describe(`sessionTests: ${printPath("[test/accountlinking/session.test.js]")}`, let epUser2 = (await EmailPassword.signUp("public", "test2@example.com", "password123")).user; - await AccountLinking.linkAccounts("public", epUser2.loginMethods[0].recipeUserId, epUser.id); + await AccountLinking.linkAccounts(epUser2.loginMethods[0].recipeUserId, epUser.id); let session = await Session.createNewSessionWithoutRequestResponse( "public", diff --git a/test/accountlinking/thirdparty.test.js b/test/accountlinking/thirdparty.test.js index 50b303131..78e0297f9 100644 --- a/test/accountlinking/thirdparty.test.js +++ b/test/accountlinking/thirdparty.test.js @@ -1162,7 +1162,7 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/thirdparty.test ).user; assert(user2.isPrimaryUser === false); - await AccountLinking.linkAccounts("public", user2.loginMethods[0].recipeUserId, user.id); + await AccountLinking.linkAccounts(user2.loginMethods[0].recipeUserId, user.id); // link accuonts above also verifies the account await EmailVerification.unverifyEmail(user2.loginMethods[0].recipeUserId); diff --git a/test/accountlinking/thirdpartyapis.test.js b/test/accountlinking/thirdpartyapis.test.js index e8aae9817..54ea63302 100644 --- a/test/accountlinking/thirdpartyapis.test.js +++ b/test/accountlinking/thirdpartyapis.test.js @@ -1446,7 +1446,6 @@ describe(`accountlinkingTests: ${printPath("[test/accountlinking/thirdpartyapis. ).user; const linkRes = await AccountLinking.linkAccounts( - "public", tpUserUnverified.loginMethods[0].recipeUserId, tpUser.id ); diff --git a/test/dashboard.test.js b/test/dashboard.test.js index ade02c824..bf0090d9e 100644 --- a/test/dashboard.test.js +++ b/test/dashboard.test.js @@ -130,11 +130,7 @@ describe(`dashboard: ${printPath("[test/dashboard.test.js]")}`, function () { ).user; assert(user.isPrimaryUser === true); let epUser = await EmailPassword.signUp("public", "test@example.com", "password123"); - const linkRes = await AccountLinking.linkAccounts( - "public", - epUser.user.loginMethods[0].recipeUserId, - user.id - ); + const linkRes = await AccountLinking.linkAccounts(epUser.user.loginMethods[0].recipeUserId, user.id); assert(linkRes.status, "OK"); let res = await request(app).get("/auth/dashboard/api/users?limit=100").expect(200); @@ -274,11 +270,7 @@ describe(`dashboard: ${printPath("[test/dashboard.test.js]")}`, function () { ).user; assert(user.isPrimaryUser === true); let epUser = await EmailPassword.signUp("public", "test@example.com", "password123"); - const linkRes = await AccountLinking.linkAccounts( - "public", - epUser.user.loginMethods[0].recipeUserId, - user.id - ); + const linkRes = await AccountLinking.linkAccounts(epUser.user.loginMethods[0].recipeUserId, user.id); assert(linkRes.status, "OK"); // TODO: validate that this should be a 200 @@ -457,11 +449,7 @@ describe(`dashboard: ${printPath("[test/dashboard.test.js]")}`, function () { ).user; assert(user.isPrimaryUser === true); let epUser = await EmailPassword.signUp("public", "test@example.com", "password123"); - const linkRes = await AccountLinking.linkAccounts( - "public", - epUser.user.loginMethods[0].recipeUserId, - user.id - ); + const linkRes = await AccountLinking.linkAccounts(epUser.user.loginMethods[0].recipeUserId, user.id); assert(linkRes.status, "OK"); const deleteRes = await request(app) @@ -535,11 +523,7 @@ describe(`dashboard: ${printPath("[test/dashboard.test.js]")}`, function () { ).user; assert(user.isPrimaryUser === true); let epUser = await EmailPassword.signUp("public", "test@example.com", "password123"); - const linkRes = await AccountLinking.linkAccounts( - "public", - epUser.user.loginMethods[0].recipeUserId, - user.id - ); + const linkRes = await AccountLinking.linkAccounts(epUser.user.loginMethods[0].recipeUserId, user.id); assert(linkRes.status, "OK"); const deleteRes = await request(app) @@ -627,11 +611,7 @@ describe(`dashboard: ${printPath("[test/dashboard.test.js]")}`, function () { ).user; assert(user.isPrimaryUser === true); let epUser = await EmailPassword.signUp("public", "test@example.com", "password123"); - const linkRes = await AccountLinking.linkAccounts( - "public", - epUser.user.loginMethods[0].recipeUserId, - user.id - ); + const linkRes = await AccountLinking.linkAccounts(epUser.user.loginMethods[0].recipeUserId, user.id); assert(linkRes.status, "OK"); const deleteRes = await request(app) diff --git a/test/with-typescript/index.ts b/test/with-typescript/index.ts index 4f66599f8..850001bd4 100644 --- a/test/with-typescript/index.ts +++ b/test/with-typescript/index.ts @@ -1,5 +1,5 @@ import * as express from "express"; -import Supertokens, { RecipeUserId } from "../.."; +import Supertokens, { RecipeUserId, User } from "../.."; import Session, { RecipeInterface, SessionClaimValidator, VerifySessionOptions } from "../../recipe/session"; import EmailVerification from "../../recipe/emailverification"; import EmailPassword from "../../recipe/emailpassword";