Skip to content

fix: dashboard / type fixes #541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

## [0.25.1] - 2024-11-08

- Fixes issues with dashboard - userroles and tenants
- Fixes `LoginMethod` to json conversion to not include `null` as values
- Adds `to_json` method to `TenantConfig`

## [0.25.0] - 2024-09-18

### Overview
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@

setup(
name="supertokens_python",
version="0.25.0",
version="0.25.1",
author="SuperTokens",
license="Apache 2.0",
author_email="[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion supertokens_python/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import annotations

SUPPORTED_CDI_VERSIONS = ["5.1"]
VERSION = "0.25.0"
VERSION = "0.25.1"
TELEMETRY = "/telemetry"
USER_COUNT = "/users/count"
USER_DELETE = "/user/remove"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ async def handle_user_put(
user_context,
)

if isinstance(email_update_response, EmailChangeNotAllowedErrorResponse):
return EmailChangeNotAllowedErrorResponse(email_update_response.error)

if not isinstance(email_update_response, OkResponse):
return email_update_response

Expand All @@ -350,6 +353,9 @@ async def handle_user_put(
user_context,
)

if isinstance(phone_update_response, PhoneNumberChangeNotAllowedErrorResponse):
return PhoneNumberChangeNotAllowedErrorResponse(phone_update_response.error)

if not isinstance(phone_update_response, OkResponse):
return phone_update_response

Expand Down
2 changes: 2 additions & 0 deletions supertokens_python/recipe/dashboard/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
CREATE_EMAIL_PASSWORD_USER = "/api/user/emailpassword"
CREATE_PASSWORDLESS_USER = "/api/user/passwordless"
UNLINK_USER = "/api/user/unlink"

USERROLES_LIST_API = "/api/userroles/roles"
USERROLES_PERMISSIONS_API = "/api/userroles/role/permissions"
USERROLES_REMOVE_PERMISSIONS_API = "/api/userroles/role/permissions/remove"
USERROLES_ROLE_API = "/api/userroles/role"
Expand Down
21 changes: 21 additions & 0 deletions supertokens_python/recipe/dashboard/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
CREATE_EMAIL_PASSWORD_USER,
CREATE_PASSWORDLESS_USER,
UNLINK_USER,
USERROLES_LIST_API,
USERROLES_PERMISSIONS_API,
USERROLES_REMOVE_PERMISSIONS_API,
USERROLES_ROLE_API,
Expand Down Expand Up @@ -198,6 +199,18 @@ def get_apis_handled(self) -> List[APIHandled]:
DASHBOARD_API,
False,
),
APIHandled(
NormalisedURLPath(get_api_path_with_dashboard_base("/roles")),
"get",
DASHBOARD_API,
False,
),
APIHandled(
NormalisedURLPath(get_api_path_with_dashboard_base("/tenants")),
"get",
DASHBOARD_API,
False,
),
APIHandled(
NormalisedURLPath(get_api_path_with_dashboard_base(SIGN_IN_API)),
"post",
Expand Down Expand Up @@ -442,6 +455,12 @@ def get_apis_handled(self) -> List[APIHandled]:
USERROLES_REMOVE_PERMISSIONS_API,
False,
),
APIHandled(
NormalisedURLPath(get_api_path_with_dashboard_base(USERROLES_LIST_API)),
"get",
USERROLES_LIST_API,
False,
),
APIHandled(
NormalisedURLPath(get_api_path_with_dashboard_base(USERROLES_ROLE_API)),
"put",
Expand Down Expand Up @@ -583,6 +602,8 @@ async def handle_api_request(
api_function = create_passwordless_user
elif request_id == UNLINK_USER:
api_function = handle_user_unlink_get
elif request_id == USERROLES_LIST_API:
api_function = get_all_roles_api
elif request_id == USERROLES_PERMISSIONS_API:
api_function = get_permissions_for_role_api
elif request_id == USERROLES_REMOVE_PERMISSIONS_API:
Expand Down
11 changes: 11 additions & 0 deletions supertokens_python/recipe/multitenancy/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ def from_json(json: Dict[str, Any]) -> TenantConfig:
required_secondary_factors=json.get("requiredSecondaryFactors", []),
)

def to_json(self) -> Dict[str, Any]:
res: Dict[str, Any] = {}
res["tenantId"] = self.tenant_id
res["thirdPartyProviders"] = [
provider.to_json() for provider in self.third_party_providers
]
res["firstFactors"] = self.first_factors
res["requiredSecondaryFactors"] = self.required_secondary_factors
res["coreConfig"] = self.core_config
return res


class TenantConfigCreateOrUpdate:
# pylint: disable=dangerous-default-value
Expand Down
12 changes: 8 additions & 4 deletions supertokens_python/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,20 @@ def has_same_third_party_info_as(
)

def to_json(self) -> Dict[str, Any]:
return {
result: Dict[str, Any] = {
"recipeId": self.recipe_id,
"recipeUserId": self.recipe_user_id.get_as_string(),
"tenantIds": self.tenant_ids,
"email": self.email,
"phoneNumber": self.phone_number,
"thirdParty": self.third_party.to_json() if self.third_party else None,
"timeJoined": self.time_joined,
"verified": self.verified,
}
if self.email is not None:
result["email"] = self.email
if self.phone_number is not None:
result["phoneNumber"] = self.phone_number
if self.third_party is not None:
result["thirdParty"] = self.third_party.to_json()
return result

@staticmethod
def from_json(json: Dict[str, Any]) -> "LoginMethod":
Expand Down
Loading