diff --git a/supertokens_python/recipe/dashboard/api/list_tenants.py b/supertokens_python/recipe/dashboard/api/list_tenants.py index 2cd777b1f..b43b9d45c 100644 --- a/supertokens_python/recipe/dashboard/api/list_tenants.py +++ b/supertokens_python/recipe/dashboard/api/list_tenants.py @@ -16,8 +16,8 @@ from typing import TYPE_CHECKING, Any, Dict, List -from supertokens_python.recipe.multitenancy.interfaces import ( - ListAllTenantsItem, +from supertokens_python.recipe.dashboard.interfaces import ( + DashboardListTenantItem ) if TYPE_CHECKING: @@ -32,9 +32,6 @@ DashboardListTenantsGetResponse, ) -from copy import deepcopy - - async def handle_list_tenants_api( _api_implementation: APIInterface, _tenant_id: str, @@ -43,11 +40,15 @@ async def handle_list_tenants_api( ) -> APIResponse: tenants = await list_all_tenants(user_context) - final_tenants: List[ListAllTenantsItem] = [] + final_tenants: List[DashboardListTenantItem] = [] 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) + dashboard_tenant = DashboardListTenantItem( + tenant_id=current_tenant.tenant_id, + emailpassword=current_tenant.emailpassword, + passwordless=current_tenant.passwordless, + third_party=current_tenant.third_party, + ) + final_tenants.append(dashboard_tenant) + + return DashboardListTenantsGetResponse(final_tenants) diff --git a/supertokens_python/recipe/dashboard/interfaces.py b/supertokens_python/recipe/dashboard/interfaces.py index f639aa8e4..0b29cc5f6 100644 --- a/supertokens_python/recipe/dashboard/interfaces.py +++ b/supertokens_python/recipe/dashboard/interfaces.py @@ -101,11 +101,38 @@ def to_json(self) -> Dict[str, Any]: } -from supertokens_python.recipe.multitenancy.interfaces import ListAllTenantsOkResult +from supertokens_python.recipe.multitenancy.interfaces import EmailPasswordConfig, PasswordlessConfig, ThirdPartyConfig +class DashboardListTenantItem: + def __init__( + self, + tenant_id: str, + emailpassword: EmailPasswordConfig, + passwordless: PasswordlessConfig, + third_party: ThirdPartyConfig, + ): + self.tenant_id = tenant_id + self.emailpassword = emailpassword + self.passwordless = passwordless + self.third_party = third_party -class DashboardListTenantsGetResponse(APIResponse, ListAllTenantsOkResult): def to_json(self): + res = { + "tenantId": self.tenant_id, + "emailpassword": self.emailpassword.to_json(), + "passwordless": self.passwordless.to_json(), + "thirdParty": self.third_party.to_json(), + } + + return res + +class DashboardListTenantsGetResponse(APIResponse): + status: str = "OK" + + def __init__(self, tenants: List[DashboardListTenantItem]) -> None: + self.tenants = tenants + + def to_json(self) -> Dict[str, Any]: return { "status": self.status, "tenants": [t.to_json() for t in self.tenants], diff --git a/supertokens_python/recipe/multitenancy/interfaces.py b/supertokens_python/recipe/multitenancy/interfaces.py index 415aad1d8..d56dd196d 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: Optional[Dict[str, Any]], + core_config: Dict[str, Any], ): self.emailpassword = emailpassword self.passwordless = passwordless @@ -131,9 +131,8 @@ def to_json(self): "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 diff --git a/supertokens_python/recipe/multitenancy/recipe_implementation.py b/supertokens_python/recipe/multitenancy/recipe_implementation.py index 2058e1ffe..195f96e85 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 or {}, + config.core_config, ) tenant_items.append(item)