Skip to content

Commit 5b8a384

Browse files
committed
fix: Make consistent with other SDKs
1 parent 0f8f60a commit 5b8a384

File tree

5 files changed

+12
-36
lines changed

5 files changed

+12
-36
lines changed

supertokens_python/always_initialised_recipes.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

supertokens_python/recipe/multitenancy/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from __future__ import annotations
1515

1616
from typing import TYPE_CHECKING, Callable, Union
17-
from supertokens_python import always_initialised_recipes
1817

1918
from . import exceptions as ex
2019
from . import recipe
@@ -42,6 +41,3 @@ def init(
4241
error_handlers,
4342
override,
4443
)
45-
46-
47-
always_initialised_recipes.DEFAULT_MULTITENANCY_RECIPE = init()

supertokens_python/recipe/session/session_class.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ async def fetch_and_set_claim(
223223
if user_context is None:
224224
user_context = {}
225225

226-
# TODO: Pass tenant id
227-
update = await claim.build(self.get_user_id(), "pass-tenant-id", user_context)
226+
update = await claim.build(
227+
self.get_user_id(), self.get_tenant_id(), user_context
228+
)
228229
return await self.merge_into_access_token_payload(update, user_context)
229230

230231
async def set_claim_value(

supertokens_python/recipe_module.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
from .exceptions import SuperTokensError
3131
from .normalised_url_path import NormalisedURLPath
3232

33-
from supertokens_python.recipe.multitenancy.recipe import MultitenancyRecipe
34-
3533

3634
class ApiIdWithTenantId:
3735
def __init__(self, api_id: str, tenant_id: str):
@@ -54,6 +52,7 @@ async def return_api_id_if_can_handle_request(
5452
self, path: NormalisedURLPath, method: str, user_context: Dict[str, Any]
5553
) -> Union[ApiIdWithTenantId, None]:
5654
from supertokens_python.recipe.multitenancy.constants import DEFAULT_TENANT_ID
55+
from supertokens_python.recipe.multitenancy.recipe import MultitenancyRecipe
5756

5857
apis_handled = self.get_apis_handled()
5958

supertokens_python/supertokens.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,20 +189,21 @@ def __init__(
189189
"Please provide at least one recipe to the supertokens.init function call"
190190
)
191191

192-
multitenancy_found = [False]
192+
from supertokens_python.recipe.multitenancy.recipe import MultitenancyRecipe
193+
194+
multitenancy_found = False
193195

194196
def make_recipe(recipe: Callable[[AppInfo], RecipeModule]) -> RecipeModule:
197+
nonlocal multitenancy_found
195198
recipe_module = recipe(self.app_info)
196-
if recipe_module.get_recipe_id() == "multitenancy":
197-
multitenancy_found[0] = True
199+
if recipe_module.get_recipe_id() == MultitenancyRecipe.recipe_id:
200+
multitenancy_found = True
198201
return recipe_module
199202

200203
self.recipe_modules: List[RecipeModule] = list(map(make_recipe, recipe_list))
201204

202-
if callable(DEFAULT_MULTITENANCY_RECIPE) and not multitenancy_found[0]:
203-
recipe = DEFAULT_MULTITENANCY_RECIPE( # pylint: disable=not-callable
204-
self.app_info
205-
)
205+
if not multitenancy_found:
206+
recipe = MultitenancyRecipe.init()(self.app_info)
206207
self.recipe_modules.append(recipe)
207208

208209
self.telemetry = (

0 commit comments

Comments
 (0)