diff --git a/supertokens_python/recipe/dashboard/api/list_tenants.py b/supertokens_python/recipe/dashboard/api/list_tenants.py index 013933c99..2cd777b1f 100644 --- a/supertokens_python/recipe/dashboard/api/list_tenants.py +++ b/supertokens_python/recipe/dashboard/api/list_tenants.py @@ -14,7 +14,11 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Dict +from typing import TYPE_CHECKING, Any, Dict, List + +from supertokens_python.recipe.multitenancy.interfaces import ( + ListAllTenantsItem, +) if TYPE_CHECKING: from supertokens_python.recipe.dashboard.interfaces import ( @@ -28,6 +32,8 @@ DashboardListTenantsGetResponse, ) +from copy import deepcopy + async def handle_list_tenants_api( _api_implementation: APIInterface, @@ -36,4 +42,12 @@ async def handle_list_tenants_api( user_context: Dict[str, Any], ) -> APIResponse: tenants = await list_all_tenants(user_context) + + final_tenants: List[ListAllTenantsItem] = [] + + for current_tenant in tenants.tenants: + modified_tenant = deepcopy(current_tenant) + modified_tenant.core_config = None + final_tenants.append(modified_tenant) + return DashboardListTenantsGetResponse(tenants.tenants) diff --git a/supertokens_python/recipe/multitenancy/interfaces.py b/supertokens_python/recipe/multitenancy/interfaces.py index dc0708d35..415aad1d8 100644 --- a/supertokens_python/recipe/multitenancy/interfaces.py +++ b/supertokens_python/recipe/multitenancy/interfaces.py @@ -101,7 +101,7 @@ def __init__( emailpassword: EmailPasswordConfig, passwordless: PasswordlessConfig, third_party: ThirdPartyConfig, - core_config: Dict[str, Any], + core_config: Optional[Dict[str, Any]], ): self.emailpassword = emailpassword self.passwordless = passwordless @@ -126,13 +126,16 @@ def __init__( self.tenant_id = tenant_id def to_json(self): - return { + res = { "tenantId": self.tenant_id, "emailpassword": self.emailpassword.to_json(), "passwordless": self.passwordless.to_json(), "thirdParty": self.third_party.to_json(), - "coreConfig": self.core_config, } + if self.core_config is not None: + res["coreConfig"] = self.core_config + + return res class ListAllTenantsOkResult: diff --git a/supertokens_python/recipe/multitenancy/recipe_implementation.py b/supertokens_python/recipe/multitenancy/recipe_implementation.py index 195f96e85..2058e1ffe 100644 --- a/supertokens_python/recipe/multitenancy/recipe_implementation.py +++ b/supertokens_python/recipe/multitenancy/recipe_implementation.py @@ -193,7 +193,7 @@ async def list_all_tenants( config.emailpassword, config.passwordless, config.third_party, - config.core_config, + config.core_config or {}, ) tenant_items.append(item)