Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/0.35' into feat/account-linking
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus committed Sep 19, 2023
2 parents cabf84f + 5818082 commit 676fc2c
Show file tree
Hide file tree
Showing 45 changed files with 188 additions and 71 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ EmailPassword.init({ // This looks the same for other recipes
})
```

## [0.34.2] - 2023-08-27

### Fixes

- Fixed the SDK trying to merge the providers from the tenant config if the third party login method is disabled.

## [0.34.1] - 2023-07-31

### Changes
Expand Down
2 changes: 1 addition & 1 deletion docs/classes/index.default.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_authRecipe.default.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_emailpassword.default.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_emailverification.default.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_multitenancy.default.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_passwordless.default.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_recipeModule.default.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_session.BooleanClaim.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_session.PrimitiveArrayClaim.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_session.PrimitiveClaim.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_session.default.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdparty.ActiveDirectory.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdparty.Apple.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdparty.Bitbucket.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdparty.BoxySAML.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdparty.Discord.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdparty.Facebook.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdparty.Github.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdparty.Gitlab.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdparty.Google.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdparty.GoogleWorkspaces.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdparty.LinkedIn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdparty.Okta.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdparty.Twitter.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdparty.default.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdpartyemailpassword.default.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_thirdpartypasswordless.default.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/recipe_userroles.default.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/modules/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/modules/recipe_emailpassword.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/modules/recipe_emailverification.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/modules/recipe_multitenancy.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/modules/recipe_passwordless.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/modules/recipe_session.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/modules/recipe_thirdparty.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/modules/recipe_thirdpartyemailpassword.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/modules/recipe_thirdpartypasswordless.html

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions lib/build/thirdparty-shared.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion lib/build/thirdparty-shared2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ export function useChildProps(recipe: Recipe | undefined): ThirdPartySignInUpChi
if (dynamicLoginMethods.loaded === false) {
throw new Error("Component requiring dynamicLoginMethods rendered without FeatureWrapper.");
} else {
tenantProviders = dynamicLoginMethods.loginMethods.thirdparty.providers;
tenantProviders = dynamicLoginMethods.loginMethods.thirdparty.enabled
? dynamicLoginMethods.loginMethods.thirdparty.providers
: [];
}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/ts/recipe/thirdparty/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ export async function redirectToThirdPartyLogin(input: {
const loginMethods = await Multitenancy.getInstanceOrThrow().getCurrentDynamicLoginMethods({
userContext: input.userContext,
});
const tenantProviders = loginMethods?.thirdparty.enabled ? loginMethods.thirdparty.providers : [];
const providers = mergeProviders({
tenantProviders: loginMethods?.thirdparty.providers,
tenantProviders,
clientProviders: input.config.signInAndUpFeature.providers,
});

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

126 changes: 114 additions & 12 deletions test/end-to-end/multitenancy.dynamic_login_methods.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {

// Examples from https://supertokens.com/docs/contribute/decisions/multitenancy/0006

it("should should show emailpassword if it's the only one added on both", async function () {
it("should show emailpassword if it's the only one added on both", async function () {
await setEnabledRecipes(page, ["emailpassword"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: true },
Expand Down Expand Up @@ -506,7 +506,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
assert.deepStrictEqual(inputNames, ["email", "password"]);
});

it("should should show thirdpartyemailpassword with emailpassword disabled if FE only has tpep but only thirdparty is enabled", async function () {
it("should show thirdpartyemailpassword with emailpassword disabled if FE only has tpep but only thirdparty is enabled", async function () {
await setEnabledRecipes(page, ["thirdpartyemailpassword"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: false },
Expand Down Expand Up @@ -534,7 +534,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
assert.deepStrictEqual(inputNames, []);
});

it("should should show thirdpartyemailpassword if FE has tpep and both emailpassword and thirdparty is enabled", async function () {
it("should show thirdpartyemailpassword if FE has tpep and both emailpassword and thirdparty is enabled", async function () {
await setEnabledRecipes(page, ["thirdpartyemailpassword"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: true },
Expand Down Expand Up @@ -563,7 +563,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
});

// This is slightly different than the version in the ADR, since it hasn't been updated
it("should should show emailpassword if FE has tp and ep but (no tpep) and both emailpassword and thirdparty is enabled", async function () {
it("should show emailpassword if FE has tp and ep but (no tpep) and both emailpassword and thirdparty is enabled", async function () {
await setEnabledRecipes(page, ["thirdparty", "emailpassword"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: true },
Expand Down Expand Up @@ -591,7 +591,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
assert.deepStrictEqual(inputNames, ["email", "password"]);
});

it("should should show thirdparty if FE has tp and pwless and both emailpassword and thirdparty is enabled", async function () {
it("should show thirdparty if FE has tp and pwless and both emailpassword and thirdparty is enabled", async function () {
await setEnabledRecipes(page, ["thirdparty", "passwordless"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: true },
Expand Down Expand Up @@ -619,7 +619,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
assert.deepStrictEqual(inputNames, []);
});

it("should should show thirdpartyemailpassword if FE has tpep and ep and both emailpassword and thirdparty is enabled", async function () {
it("should show thirdpartyemailpassword if FE has tpep and ep and both emailpassword and thirdparty is enabled", async function () {
await setEnabledRecipes(page, ["thirdpartyemailpassword", "emailpassword"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: true },
Expand Down Expand Up @@ -647,7 +647,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
assert.deepStrictEqual(inputNames, ["email", "password"]);
});

it("should should show thirdpartypasswordless if FE has tppwless and ep and both emailpassword and thirdparty is enabled", async function () {
it("should show thirdpartypasswordless if FE has tppwless and ep and both emailpassword and thirdparty is enabled", async function () {
await setEnabledRecipes(page, ["thirdpartypasswordless", "emailpassword"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: true },
Expand Down Expand Up @@ -675,7 +675,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
assert.deepStrictEqual(inputNames, []);
});

it("should should show thirdpartyemailpassword if FE has tpep and tppwless and all 3 enabled in core", async function () {
it("should show thirdpartyemailpassword if FE has tpep and tppwless and all 3 enabled in core", async function () {
await setEnabledRecipes(page, ["thirdpartypasswordless", "thirdpartyemailpassword"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: true },
Expand Down Expand Up @@ -703,7 +703,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
assert.deepStrictEqual(inputNames, ["email", "password"]);
});

it("should should show thirdpartypwless if rid has FE has tpep and tppwless and all 3 enabled in core", async function () {
it("should show thirdpartypwless if rid has FE has tpep and tppwless and all 3 enabled in core", async function () {
await setEnabledRecipes(page, ["thirdpartypasswordless", "thirdpartyemailpassword"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: true },
Expand Down Expand Up @@ -731,7 +731,109 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
assert.deepStrictEqual(inputNames, ["email", "password"]);
});

it("should should show something went wrong if logging in with disabled method", async function () {
it("should show thirdpartyemailpassword if FE has only tpep and thirdparty is disbled in core", async function () {
await setEnabledRecipes(page, ["thirdpartyemailpassword"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: true },
passwordless: { enabled: true },
thirdParty: {
enabled: false,
providers: [],
},
});

await Promise.all([
page.goto(`${TEST_CLIENT_BASE_URL}${DEFAULT_WEBSITE_BASE_PATH}`),
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);

// Thirdparty
const providers = await getProvidersLabels(page);
assert.strictEqual(providers.length, 0);
assert.strictEqual(await getProviderLogoCount(page), 0);

// Emailpassword
const inputNames = await getInputNames(page);
assert.deepStrictEqual(inputNames, ["email", "password"]);
});

it("should show thirdpartyemailpassword if FE has only tpep and thirdparty is disbled in core", async function () {
await setEnabledRecipes(page, ["thirdpartyemailpassword"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: false },
passwordless: { enabled: false },
thirdParty: {
enabled: true,
providers: [],
},
});

await Promise.all([
page.goto(`${TEST_CLIENT_BASE_URL}${DEFAULT_WEBSITE_BASE_PATH}`),
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);

// Thirdparty
const providers = await getProvidersLabels(page);
assert.notStrictEqual(providers.length, 0);
assert.notStrictEqual(await getProviderLogoCount(page), 0);

// Emailpassword
const inputNames = await getInputNames(page);
assert.deepStrictEqual(inputNames, []);
});

it("should show thirdpartpasswordless if FE has only tppwless and thirdparty is disbled in core", async function () {
await setEnabledRecipes(page, ["thirdpartypasswordless"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: true },
passwordless: { enabled: true },
thirdParty: {
enabled: false,
providers: [],
},
});

await Promise.all([
page.goto(`${TEST_CLIENT_BASE_URL}${DEFAULT_WEBSITE_BASE_PATH}`),
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);

// Thirdparty
const providers = await getProvidersLabels(page);
assert.strictEqual(providers.length, 0);
assert.strictEqual(await getProviderLogoCount(page), 0);

// pwless
await waitForSTElement(page, "[data-supertokens~=input][name=emailOrPhone]");
});

it("should show thirdpartpasswordless if FE has only tppwless and passwordless is disbled in core", async function () {
await setEnabledRecipes(page, ["thirdpartypasswordless"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: false },
passwordless: { enabled: false },
thirdParty: {
enabled: true,
providers: [],
},
});

await Promise.all([
page.goto(`${TEST_CLIENT_BASE_URL}${DEFAULT_WEBSITE_BASE_PATH}`),
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);

// Thirdparty
const providers = await getProvidersLabels(page);
assert.notStrictEqual(providers.length, 0);
assert.notStrictEqual(await getProviderLogoCount(page), 0);

// pwless
await waitForSTElement(page, "[data-supertokens~=input][name=emailOrPhone]", true);
});

it("should show something went wrong if logging in with disabled method", async function () {
await setEnabledRecipes(page, ["emailpassword"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: false },
Expand Down Expand Up @@ -769,7 +871,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
assert.strictEqual(error, SOMETHING_WENT_WRONG_ERROR);
});

it("should should show thirdparty if FE has tp and pwless and both emailpassword and thirdparty is enabled", async function () {
it("should show thirdparty if FE has tp and pwless and both emailpassword and thirdparty is enabled", async function () {
await setEnabledRecipes(page, ["thirdparty", "passwordless"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: true },
Expand Down Expand Up @@ -797,7 +899,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {
assert.deepStrictEqual(inputNames, []);
});

it("should should be able to log in with dynamically added tp providers", async function () {
it("should be able to log in with dynamically added tp providers", async function () {
await setEnabledRecipes(page, ["thirdparty"]);
await enableDynamicLoginMethods(page, {
emailPassword: { enabled: false },
Expand Down

0 comments on commit 676fc2c

Please sign in to comment.