Skip to content

Commit 030d7ce

Browse files
authored
fix: dashboard / type fixes (#541)
* fix: dashboard * fix: adding missing to_json function in TenantConfig * fix: version and changelog * fix: login methods and user put
1 parent 5410c8a commit 030d7ce

File tree

8 files changed

+56
-6
lines changed

8 files changed

+56
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [unreleased]
1010

11+
## [0.25.1] - 2024-11-08
12+
13+
- Fixes issues with dashboard - userroles and tenants
14+
- Fixes `LoginMethod` to json conversion to not include `null` as values
15+
- Adds `to_json` method to `TenantConfig`
16+
1117
## [0.25.0] - 2024-09-18
1218

1319
### Overview

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
setup(
9191
name="supertokens_python",
92-
version="0.25.0",
92+
version="0.25.1",
9393
author="SuperTokens",
9494
license="Apache 2.0",
9595
author_email="[email protected]",

supertokens_python/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from __future__ import annotations
1616

1717
SUPPORTED_CDI_VERSIONS = ["5.1"]
18-
VERSION = "0.25.0"
18+
VERSION = "0.25.1"
1919
TELEMETRY = "/telemetry"
2020
USER_COUNT = "/users/count"
2121
USER_DELETE = "/user/remove"

supertokens_python/recipe/dashboard/api/userdetails/user_put.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ async def handle_user_put(
339339
user_context,
340340
)
341341

342+
if isinstance(email_update_response, EmailChangeNotAllowedErrorResponse):
343+
return EmailChangeNotAllowedErrorResponse(email_update_response.error)
344+
342345
if not isinstance(email_update_response, OkResponse):
343346
return email_update_response
344347

@@ -350,6 +353,9 @@ async def handle_user_put(
350353
user_context,
351354
)
352355

356+
if isinstance(phone_update_response, PhoneNumberChangeNotAllowedErrorResponse):
357+
return PhoneNumberChangeNotAllowedErrorResponse(phone_update_response.error)
358+
353359
if not isinstance(phone_update_response, OkResponse):
354360
return phone_update_response
355361

supertokens_python/recipe/dashboard/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
CREATE_EMAIL_PASSWORD_USER = "/api/user/emailpassword"
2222
CREATE_PASSWORDLESS_USER = "/api/user/passwordless"
2323
UNLINK_USER = "/api/user/unlink"
24+
25+
USERROLES_LIST_API = "/api/userroles/roles"
2426
USERROLES_PERMISSIONS_API = "/api/userroles/role/permissions"
2527
USERROLES_REMOVE_PERMISSIONS_API = "/api/userroles/role/permissions/remove"
2628
USERROLES_ROLE_API = "/api/userroles/role"

supertokens_python/recipe/dashboard/recipe.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
CREATE_EMAIL_PASSWORD_USER,
143143
CREATE_PASSWORDLESS_USER,
144144
UNLINK_USER,
145+
USERROLES_LIST_API,
145146
USERROLES_PERMISSIONS_API,
146147
USERROLES_REMOVE_PERMISSIONS_API,
147148
USERROLES_ROLE_API,
@@ -198,6 +199,18 @@ def get_apis_handled(self) -> List[APIHandled]:
198199
DASHBOARD_API,
199200
False,
200201
),
202+
APIHandled(
203+
NormalisedURLPath(get_api_path_with_dashboard_base("/roles")),
204+
"get",
205+
DASHBOARD_API,
206+
False,
207+
),
208+
APIHandled(
209+
NormalisedURLPath(get_api_path_with_dashboard_base("/tenants")),
210+
"get",
211+
DASHBOARD_API,
212+
False,
213+
),
201214
APIHandled(
202215
NormalisedURLPath(get_api_path_with_dashboard_base(SIGN_IN_API)),
203216
"post",
@@ -442,6 +455,12 @@ def get_apis_handled(self) -> List[APIHandled]:
442455
USERROLES_REMOVE_PERMISSIONS_API,
443456
False,
444457
),
458+
APIHandled(
459+
NormalisedURLPath(get_api_path_with_dashboard_base(USERROLES_LIST_API)),
460+
"get",
461+
USERROLES_LIST_API,
462+
False,
463+
),
445464
APIHandled(
446465
NormalisedURLPath(get_api_path_with_dashboard_base(USERROLES_ROLE_API)),
447466
"put",
@@ -583,6 +602,8 @@ async def handle_api_request(
583602
api_function = create_passwordless_user
584603
elif request_id == UNLINK_USER:
585604
api_function = handle_user_unlink_get
605+
elif request_id == USERROLES_LIST_API:
606+
api_function = get_all_roles_api
586607
elif request_id == USERROLES_PERMISSIONS_API:
587608
api_function = get_permissions_for_role_api
588609
elif request_id == USERROLES_REMOVE_PERMISSIONS_API:

supertokens_python/recipe/multitenancy/interfaces.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ def from_json(json: Dict[str, Any]) -> TenantConfig:
5656
required_secondary_factors=json.get("requiredSecondaryFactors", []),
5757
)
5858

59+
def to_json(self) -> Dict[str, Any]:
60+
res: Dict[str, Any] = {}
61+
res["tenantId"] = self.tenant_id
62+
res["thirdPartyProviders"] = [
63+
provider.to_json() for provider in self.third_party_providers
64+
]
65+
res["firstFactors"] = self.first_factors
66+
res["requiredSecondaryFactors"] = self.required_secondary_factors
67+
res["coreConfig"] = self.core_config
68+
return res
69+
5970

6071
class TenantConfigCreateOrUpdate:
6172
# pylint: disable=dangerous-default-value

supertokens_python/types.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,20 @@ def has_same_third_party_info_as(
131131
)
132132

133133
def to_json(self) -> Dict[str, Any]:
134-
return {
134+
result: Dict[str, Any] = {
135135
"recipeId": self.recipe_id,
136136
"recipeUserId": self.recipe_user_id.get_as_string(),
137137
"tenantIds": self.tenant_ids,
138-
"email": self.email,
139-
"phoneNumber": self.phone_number,
140-
"thirdParty": self.third_party.to_json() if self.third_party else None,
141138
"timeJoined": self.time_joined,
142139
"verified": self.verified,
143140
}
141+
if self.email is not None:
142+
result["email"] = self.email
143+
if self.phone_number is not None:
144+
result["phoneNumber"] = self.phone_number
145+
if self.third_party is not None:
146+
result["thirdParty"] = self.third_party.to_json()
147+
return result
144148

145149
@staticmethod
146150
def from_json(json: Dict[str, Any]) -> "LoginMethod":

0 commit comments

Comments
 (0)