Skip to content

Commit

Permalink
refactor: Remove core config from dashboard tenants list response
Browse files Browse the repository at this point in the history
  • Loading branch information
KShivendu committed Aug 10, 2023
1 parent 0e10bf5 commit 6f02fcf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
16 changes: 15 additions & 1 deletion supertokens_python/recipe/dashboard/api/list_tenants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -28,6 +32,8 @@
DashboardListTenantsGetResponse,
)

from copy import deepcopy


async def handle_list_tenants_api(
_api_implementation: APIInterface,
Expand All @@ -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)
9 changes: 6 additions & 3 deletions supertokens_python/recipe/multitenancy/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 6f02fcf

Please sign in to comment.