From fdefc5b5105a3b0a4fc1064f4aa1669e126f1cc4 Mon Sep 17 00:00:00 2001 From: KShivendu Date: Mon, 24 Jul 2023 14:49:29 +0530 Subject: [PATCH] fix: Change order of tenant_id in the params --- .../recipe/userroles/asyncio/__init__.py | 8 ++++---- supertokens_python/recipe/userroles/interfaces.py | 8 ++++---- supertokens_python/recipe/userroles/recipe.py | 4 ++-- .../recipe/userroles/recipe_implementation.py | 8 ++++---- supertokens_python/recipe/userroles/syncio/__init__.py | 10 ++++++++-- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/supertokens_python/recipe/userroles/asyncio/__init__.py b/supertokens_python/recipe/userroles/asyncio/__init__.py index 61665da61..4885bbd7f 100644 --- a/supertokens_python/recipe/userroles/asyncio/__init__.py +++ b/supertokens_python/recipe/userroles/asyncio/__init__.py @@ -25,7 +25,7 @@ async def add_role_to_user( if user_context is None: user_context = {} return await UserRolesRecipe.get_instance().recipe_implementation.add_role_to_user( - tenant_id, user_id, role, user_context + user_id, role, tenant_id, user_context ) @@ -38,7 +38,7 @@ async def remove_user_role( if user_context is None: user_context = {} return await UserRolesRecipe.get_instance().recipe_implementation.remove_user_role( - tenant_id, user_id, role, user_context + user_id, role, tenant_id, user_context ) @@ -49,7 +49,7 @@ async def get_roles_for_user( user_context = {} return ( await UserRolesRecipe.get_instance().recipe_implementation.get_roles_for_user( - tenant_id, user_id, user_context + user_id, tenant_id, user_context ) ) @@ -60,7 +60,7 @@ async def get_users_that_have_role( if user_context is None: user_context = {} return await UserRolesRecipe.get_instance().recipe_implementation.get_users_that_have_role( - tenant_id, role, user_context + role, tenant_id, user_context ) diff --git a/supertokens_python/recipe/userroles/interfaces.py b/supertokens_python/recipe/userroles/interfaces.py index b8b160156..f18a96e1f 100644 --- a/supertokens_python/recipe/userroles/interfaces.py +++ b/supertokens_python/recipe/userroles/interfaces.py @@ -58,25 +58,25 @@ def __init__(self, roles: List[str]): class RecipeInterface(ABC): @abstractmethod async def add_role_to_user( - self, tenant_id: str, user_id: str, role: str, user_context: Dict[str, Any] + self, user_id: str, role: str, tenant_id: str, user_context: Dict[str, Any] ) -> Union[AddRoleToUserOkResult, UnknownRoleError]: pass @abstractmethod async def remove_user_role( - self, tenant_id: str, user_id: str, role: str, user_context: Dict[str, Any] + self, user_id: str, role: str, tenant_id: str, user_context: Dict[str, Any] ) -> Union[RemoveUserRoleOkResult, UnknownRoleError]: pass @abstractmethod async def get_roles_for_user( - self, tenant_id: str, user_id: str, user_context: Dict[str, Any] + self, user_id: str, tenant_id: str, user_context: Dict[str, Any] ) -> GetRolesForUserOkResult: pass @abstractmethod async def get_users_that_have_role( - self, tenant_id: str, role: str, user_context: Dict[str, Any] + self, role: str, tenant_id: str, user_context: Dict[str, Any] ) -> Union[GetUsersThatHaveRoleOkResult, UnknownRoleError]: pass diff --git a/supertokens_python/recipe/userroles/recipe.py b/supertokens_python/recipe/userroles/recipe.py index f6ea2a76e..66e60996f 100644 --- a/supertokens_python/recipe/userroles/recipe.py +++ b/supertokens_python/recipe/userroles/recipe.py @@ -151,7 +151,7 @@ async def fetch_value( recipe = UserRolesRecipe.get_instance() user_roles = await recipe.recipe_implementation.get_roles_for_user( - user_id, tenant_id, user_context + tenant_id, user_id, user_context ) user_permissions: Set[str] = set() @@ -185,7 +185,7 @@ async def fetch_value( ) -> List[str]: recipe = UserRolesRecipe.get_instance() res = await recipe.recipe_implementation.get_roles_for_user( - user_id, tenant_id, user_context + tenant_id, user_id, user_context ) return res.roles diff --git a/supertokens_python/recipe/userroles/recipe_implementation.py b/supertokens_python/recipe/userroles/recipe_implementation.py index f36440531..bcf0dccd9 100644 --- a/supertokens_python/recipe/userroles/recipe_implementation.py +++ b/supertokens_python/recipe/userroles/recipe_implementation.py @@ -40,7 +40,7 @@ def __init__(self, querier: Querier): self.querier = querier async def add_role_to_user( - self, tenant_id: str, user_id: str, role: str, user_context: Dict[str, Any] + self, user_id: str, role: str, tenant_id: str, user_context: Dict[str, Any] ) -> Union[AddRoleToUserOkResult, UnknownRoleError]: params = {"userId": user_id, "role": role} response = await self.querier.send_put_request( @@ -53,7 +53,7 @@ async def add_role_to_user( return UnknownRoleError() async def remove_user_role( - self, tenant_id: str, user_id: str, role: str, user_context: Dict[str, Any] + self, user_id: str, role: str, tenant_id: str, user_context: Dict[str, Any] ) -> Union[RemoveUserRoleOkResult, UnknownRoleError]: params = {"userId": user_id, "role": role} response = await self.querier.send_post_request( @@ -66,7 +66,7 @@ async def remove_user_role( return UnknownRoleError() async def get_roles_for_user( - self, tenant_id: str, user_id: str, user_context: Dict[str, Any] + self, user_id: str, tenant_id: str, user_context: Dict[str, Any] ) -> GetRolesForUserOkResult: params = {"userId": user_id} response = await self.querier.send_get_request( @@ -75,7 +75,7 @@ async def get_roles_for_user( return GetRolesForUserOkResult(roles=response["roles"]) async def get_users_that_have_role( - self, tenant_id: str, role: str, user_context: Dict[str, Any] + self, role: str, tenant_id: str, user_context: Dict[str, Any] ) -> Union[GetUsersThatHaveRoleOkResult, UnknownRoleError]: params = {"role": role} response = await self.querier.send_get_request( diff --git a/supertokens_python/recipe/userroles/syncio/__init__.py b/supertokens_python/recipe/userroles/syncio/__init__.py index 2025e06e1..8cb30ad82 100644 --- a/supertokens_python/recipe/userroles/syncio/__init__.py +++ b/supertokens_python/recipe/userroles/syncio/__init__.py @@ -31,7 +31,10 @@ def add_role_to_user( - tenant_id: str, user_id: str, role: str, user_context: Union[Dict[str, Any], None] = None + tenant_id: str, + user_id: str, + role: str, + user_context: Union[Dict[str, Any], None] = None, ) -> Union[AddRoleToUserOkResult, UnknownRoleError]: from supertokens_python.recipe.userroles.asyncio import add_role_to_user @@ -39,7 +42,10 @@ def add_role_to_user( def remove_user_role( - tenant_id: str, user_id: str, role: str, user_context: Union[Dict[str, Any], None] = None + tenant_id: str, + user_id: str, + role: str, + user_context: Union[Dict[str, Any], None] = None, ) -> Union[RemoveUserRoleOkResult, UnknownRoleError]: from supertokens_python.recipe.userroles.asyncio import remove_user_role