Skip to content

Commit

Permalink
fix: Change order of tenant_id in the params
Browse files Browse the repository at this point in the history
  • Loading branch information
KShivendu committed Jul 24, 2023
1 parent dc3c493 commit fdefc5b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
8 changes: 4 additions & 4 deletions supertokens_python/recipe/userroles/asyncio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)


Expand All @@ -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
)


Expand All @@ -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
)
)

Expand All @@ -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
)


Expand Down
8 changes: 4 additions & 4 deletions supertokens_python/recipe/userroles/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions supertokens_python/recipe/userroles/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions supertokens_python/recipe/userroles/recipe_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down
10 changes: 8 additions & 2 deletions supertokens_python/recipe/userroles/syncio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,21 @@


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

return sync(add_role_to_user(tenant_id, user_id, role, user_context))


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

Expand Down

0 comments on commit fdefc5b

Please sign in to comment.