Actions
dev #2961
openDescription
Summary¶
This feature enhances the user management system with safer deletion workflows, and bulk operations. It introduces improves query safety by using Drizzle helpers, and adds comprehensive bulk deletion support for admins. The changes also strengthen error handling and ensure safe deletion processes with database transactions.
Changes¶
2. Delete API Enhancements¶
-
Admin Delete Updates
- Accept userIds as a comma-separated string for bulk processing.
- Generate
toolActionsobjects for all tools owned by the selected users.
3. Bulk Delete Functionality¶
-
New Features
- Implemented bulk delete for admins, allowing multiple users to be deleted at once.
- Updated
statusandverificationMethodin thetoolVerificationstable so tools can be reclaimed by new owners later.
-
Transaction Safety
- Used database transactions for user deletions (both admin and non-admin) to ensure safe, atomic operations.
4. Error Handling¶
-
Error Context
- Updated
errorHandlerforFORBIDDENerrors to include detailed error context.
- Updated
Example Usage¶
Bulk Delete for Admin¶
Request Body
{
"userIdsToDelete":"47,45"
}
Expected Response
{
"success": true,
"message": "Users deleted successfully",
"usersDeleted": [
"47",
"45"
]
}
Normal Delete for Non-Admin¶
Request Body
{
"toolActions": [
{ "toolId": "f13ae2e9-5f6c-4d65-835c-958fb7ecf746", "action": "delete" },
{ "toolId": "c6869a87-09eb-450a-b7fb-f2ac8961c6cf", "action": "transfer", "newOwnerId": 2 }
]
}
Expected Response
{
"success": true,
"message": "Users deleted successfully",
"usersDeleted": [
"57"
]
}
Actions