Project

General

Profile

Actions

dev #2961

open

dev #2956: [Module] Sprint 13

dev #2959: [BE] Admin Dashboard apis

[BE] User bulk actions (delete)

Added by Zahid Hassan 8 months ago. Updated 8 months ago.

Status:
Complete
Priority:
High
Assignee:
Target version:
Start date:
08/21/2025
Due date:
% Done:

100%

Estimated time:
4:00 h
Spent time:

Description

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 toolActions objects 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 status and verificationMethod in the toolVerifications table 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 errorHandler for FORBIDDEN errors to include detailed error context.

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 #1

Updated by Zahid Hassan 8 months ago

  • Status changed from Pending to In Progress
  • % Done changed from 0 to 20
Actions #2

Updated by Zahid Hassan 8 months ago

  • Subject changed from [BE] User bulk actions (multi select, delete) single update to [BE] User bulk actions (delete)
  • Description updated (diff)
  • Status changed from In Progress to Complete
  • % Done changed from 20 to 100
Actions

Also available in: Atom PDF