flip_api.user_services.retrieve_user_permissions

Attributes

router

Functions

has_role(→ bool)

Check if a user has at least one role assigned.

get_user_permissions(...)

Retrieve all permissions for a given user based on their roles.

retrieve_user_permissions(, token_id)

Retrieves the list of permissions associated with a specific user ID.

Module Contents

flip_api.user_services.retrieve_user_permissions.router
flip_api.user_services.retrieve_user_permissions.has_role(user_id: uuid.UUID, db: sqlmodel.Session) bool

Check if a user has at least one role assigned.

Parameters:
  • user_id (UUID) – The unique identifier of the user.

  • db (Session) – The database session.

Returns:

True if the user has at least one role, False otherwise.

Return type:

bool

flip_api.user_services.retrieve_user_permissions.get_user_permissions(user_id: uuid.UUID, db: sqlmodel.Session) list[flip_api.db.models.user_models.Permission]

Retrieve all permissions for a given user based on their roles.

Parameters:
  • user_id (UUID) – The unique identifier of the user.

  • db (Session) – The database session.

Returns:

A list of Permission objects associated with the user’s roles.

Return type:

list[Permission]

flip_api.user_services.retrieve_user_permissions.retrieve_user_permissions(user_id: uuid.UUID, db: sqlmodel.Session = Depends(get_session), token_id: uuid.UUID = Depends(verify_token)) flip_api.domain.schemas.users.UserPermissionsResponse

Retrieves the list of permissions associated with a specific user ID.

Parameters:
  • user_id (UUID) – The unique identifier of the user whose permissions are being retrieved.

  • db (Session) – The database session, provided by dependency injection.

  • token_id (UUID) – The unique identifier of the authenticated user making the request.

Returns:

An object containing a list of permissions associated with the user.

Return type:

UserPermissionsResponse

Raises:
  • HTTPException – If the user ID does not match the token ID (i.e., users can only access their own permissions),

  • if the user does not exist or has no roles assigned, or if there is an unexpected error while retrieving

  • permissions.