-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: multitenancy #677
feat: multitenancy #677
Conversation
Co-authored-by: Mihály Lengyel <mihaly@lengyel.tech>
Co-authored-by: Mihály Lengyel <mihaly@lengyel.tech>
Please manually test/add test cases for combination recipes with disabled sub-recipe:
|
only thirdparty is rendered, using emailpassword and passwordless is not possible, i think thats what we need |
lib/ts/recipe/multitenancy/recipe.ts
Outdated
passwordless: { ...passwordless, enabled: false }, | ||
emailpassword: { ...emailPassword, enabled: true }, | ||
thirdparty: { ...thirdParty, enabled: true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems wrong..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this a testing change? It's still there.
@@ -41,11 +41,11 @@ const SignInAndUpTheme: React.FC<ThirdPartyEmailPasswordSignInAndUpThemeProps> = | |||
const usesDynamicLoginMethods = SuperTokens.usesDynamicLoginMethods; | |||
const dynamicLoginMethods = Multitenancy.getInstanceOrThrow().getLoadedDynamicLoginMethods(); | |||
const thirdPartyEnabled = | |||
(props.config.disableEmailPassword === false && usesDynamicLoginMethods === false) || | |||
usesDynamicLoginMethods === false || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we not checking the provider count in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean like (usesDynamicLoginMethods === false || providers.length > 0) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usesDynamicLoginMethods === false && providers.length > 0
SuperTokens.usesDynamicLoginMethods === false && | ||
config.thirdPartyConfig?.signInAndUpFeature.providers.length === 0 | ||
) { | ||
throw new Error("ThirdParty signInAndUpFeature providers array cannot be empty."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be empty (which means the thirdparty section is disabled) if email password is not disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you want me to remove this check ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This only needs to throw if all of the following is true:
- email password is disabled (this would be passwordless in the thirdpartypasswordless case)
- thirdparty provider list is empty
- not using dynamic login methods.
lib/ts/recipe/recipeRouter/index.tsx
Outdated
const dynamicLoginMethods = Multitenancy.getInstanceOrThrow().getLoadedDynamicLoginMethods(); | ||
const possiblyEnabledRecipes = { | ||
thirdpartyemailpassword: { | ||
enabled: dynamicLoginMethods?.["thirdparty"].enabled && dynamicLoginMethods["emailpassword"].enabled, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the second case in the ADR examples works as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its working fine
lib/ts/recipe/recipeRouter/index.tsx
Outdated
return matching; | ||
} | ||
} | ||
|
||
// Otherwise, If no recipe Id provided, or if no recipe id matches, return the first matching component. | ||
return routeComponents[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please throw in this case:
- we found no enabled recipes handling the current route
- even if we render the route no actions on it will work since the recipe is disabled on the backend.
lib/ts/recipe/multitenancy/utils.ts
Outdated
@@ -90,11 +90,12 @@ export const mergeProviders = ({ | |||
const providers: Pick<Provider, "id" | "buttonComponent" | "getButton">[] = []; | |||
|
|||
for (const tenantProvider of tenantProviders) { | |||
// try finding exact match first | |||
// try finding exact match or client provider that includes tenant id | |||
let provider = clientProviders.find((provider) => { | |||
const { id } = tenantProvider; | |||
return provider.id === id || provider.id.includes(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This includes
is a bit strange to me here. Could you point me to the docs about this merging algorithm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can remove this include, i dont remember why i added this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few older comments that haven't been addressed.
lib/ts/recipe/recipeRouter/index.tsx
Outdated
@@ -24,7 +24,7 @@ export abstract class RecipeRouter { | |||
} | |||
|
|||
const dynamicLoginMethods = Multitenancy.getInstanceOrThrow().getLoadedDynamicLoginMethods(); | |||
const possiblyEnabledRecipes = { | |||
const componentMatchingRid = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const componentMatchingRid = { | |
const possiblyEnabledRecipes = { |
lib/ts/recipe/recipeRouter/index.tsx
Outdated
@@ -33,20 +33,20 @@ export abstract class RecipeRouter { | |||
}, | |||
...dynamicLoginMethods, | |||
}; | |||
const components = routeComponents.filter((c) => c.matches()); | |||
const component = routeComponents.find((c) => c.matches()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const component = routeComponents.find((c) => c.matches()); | |
const componentMatchingRid = routeComponents.find((c) => c.matches()); |
* wip: tests * test: additional tests * fix: picking providers logic & types * test: adds test case * fix test & remove redundant test case * fix: minor cleanup/small fix + test extension --------- Co-authored-by: Alisher <alisher@supertokens.com> Co-authored-by: Mihaly Lengyel <mihaly@lengyel.tech>
@@ -36,23 +36,44 @@ supertokens.init({ | |||
providers: [ | |||
// We have provided you with development keys which you can use for testing. | |||
// IMPORTANT: Please replace them with your own OAuth keys for production use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undo all changes in example apps.
Summary of change
Multitenancy feature
Related issues
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!)
Documentation changes
(If relevant, please create a PR in our docs repo, or create a checklist here highlighting the necessary changes)
Checklist for important updates
frontendDriverInterfaceSupported.json
file has been updated (if needed)package.json
package-lock.json
lib/ts/version.ts
npm run build-pretty
git tag
) in the formatvX.Y.Z
, and then find the latest branch (git branch --all
) whoseX.Y
is greater than the latest released tag.someFunc: function () {..}
).size-limit
section ofpackage.json
with the size limit set to the current size rounded up.rollup.config.mjs
Remaining TODOs for this PR