pub async fn remove_role_from_user(
pool: &Pool<MySql>,
user_id: i64,
role_id: i64,
) -> Result<()>
Expand description
Removes a role from a user.
This function deletes the association between a user and a role, revoking all permissions granted by that role from the user. This is used to adjust user access in the RBAC system.
§Arguments
pool
- Database connection pool for executing the queryuser_id
- Unique identifier of the user from whom to remove the rolerole_id
- Unique identifier of the role to remove
§Returns
Ok(())
- Successfully removed the role from the userErr(anyhow::Error)
- Failed to remove the role
§Transaction Handling
This function uses a database transaction to ensure atomicity of the operation. If any part of the operation fails, the entire operation is rolled back.
§Note
After this operation, the user will no longer have the permissions granted by this role, unless they have other roles that include the same permissions.