Skip to content

Commit 488e367

Browse files
Merge pull request #401 from supertokens/fix/tp-rework-dashboard
refactor: Remove core config from dashboard tenants list response
2 parents fc4286b + 2041a5d commit 488e367

File tree

3 files changed

+54
-5
lines changed

3 files changed

+54
-5
lines changed

supertokens_python/recipe/dashboard/api/list_tenants.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
from __future__ import annotations
1616

17-
from typing import TYPE_CHECKING, Any, Dict
17+
from typing import TYPE_CHECKING, Any, Dict, List
18+
19+
from supertokens_python.recipe.dashboard.interfaces import DashboardListTenantItem
1820

1921
if TYPE_CHECKING:
2022
from supertokens_python.recipe.dashboard.interfaces import (
@@ -36,4 +38,16 @@ async def handle_list_tenants_api(
3638
user_context: Dict[str, Any],
3739
) -> APIResponse:
3840
tenants = await list_all_tenants(user_context)
39-
return DashboardListTenantsGetResponse(tenants.tenants)
41+
42+
final_tenants: List[DashboardListTenantItem] = []
43+
44+
for current_tenant in tenants.tenants:
45+
dashboard_tenant = DashboardListTenantItem(
46+
tenant_id=current_tenant.tenant_id,
47+
emailpassword=current_tenant.emailpassword,
48+
passwordless=current_tenant.passwordless,
49+
third_party=current_tenant.third_party,
50+
)
51+
final_tenants.append(dashboard_tenant)
52+
53+
return DashboardListTenantsGetResponse(final_tenants)

supertokens_python/recipe/dashboard/interfaces.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,44 @@ def to_json(self) -> Dict[str, Any]:
101101
}
102102

103103

104-
from supertokens_python.recipe.multitenancy.interfaces import ListAllTenantsOkResult
104+
from supertokens_python.recipe.multitenancy.interfaces import (
105+
EmailPasswordConfig,
106+
PasswordlessConfig,
107+
ThirdPartyConfig,
108+
)
105109

106110

107-
class DashboardListTenantsGetResponse(APIResponse, ListAllTenantsOkResult):
111+
class DashboardListTenantItem:
112+
def __init__(
113+
self,
114+
tenant_id: str,
115+
emailpassword: EmailPasswordConfig,
116+
passwordless: PasswordlessConfig,
117+
third_party: ThirdPartyConfig,
118+
):
119+
self.tenant_id = tenant_id
120+
self.emailpassword = emailpassword
121+
self.passwordless = passwordless
122+
self.third_party = third_party
123+
108124
def to_json(self):
125+
res = {
126+
"tenantId": self.tenant_id,
127+
"emailpassword": self.emailpassword.to_json(),
128+
"passwordless": self.passwordless.to_json(),
129+
"thirdParty": self.third_party.to_json(),
130+
}
131+
132+
return res
133+
134+
135+
class DashboardListTenantsGetResponse(APIResponse):
136+
status: str = "OK"
137+
138+
def __init__(self, tenants: List[DashboardListTenantItem]) -> None:
139+
self.tenants = tenants
140+
141+
def to_json(self) -> Dict[str, Any]:
109142
return {
110143
"status": self.status,
111144
"tenants": [t.to_json() for t in self.tenants],

supertokens_python/recipe/multitenancy/interfaces.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,16 @@ def __init__(
126126
self.tenant_id = tenant_id
127127

128128
def to_json(self):
129-
return {
129+
res = {
130130
"tenantId": self.tenant_id,
131131
"emailpassword": self.emailpassword.to_json(),
132132
"passwordless": self.passwordless.to_json(),
133133
"thirdParty": self.third_party.to_json(),
134134
"coreConfig": self.core_config,
135135
}
136136

137+
return res
138+
137139

138140
class ListAllTenantsOkResult:
139141
status = "OK"

0 commit comments

Comments
 (0)