Skip to content

### **Title:** Implement Full User CRUD Functionality in User Service #17

@agaesh

Description

@agaesh

Description:

Build the complete Create, Read, Update, and Delete (CRUD) operations for managing users in the system. Reuse existing registerUser logic for creating users. This feature is essential for the admin panel and backend management tools.


✅ Tasks Checklist:

➕ Create User

  • Create new endpoint: POST /admin/add-user
  • Internally call registerUser() method
  • Validate required fields (e.g., name, email, password, role)
  • Hash password before storing
  • Return success/error response
  • Ensure admin-level authorization

📥 Get All Users

  • Endpoint: GET /users
  • Support pagination and filtering (optional)
  • Return user list with metadata (e.g., count, page)

🔍 Get User by ID

  • Endpoint: GET /users/:id
  • Validate ID format
  • Return 404 if user not found
  • Return user data

✏️ Update User

  • Endpoint: PUT /users/:id
  • Allow updating name, email, role (optional password reset)
  • Validate inputs
  • Hash new password (if provided)
  • Return updated user object

❌ Delete User

  • Endpoint: DELETE /users/:id
  • Decide on soft delete (e.g., set isDeleted=true) or hard delete
  • Return confirmation response

🧪 Testing

  • Unit tests for all endpoints
  • Integration tests for full flow

📝 Documentation

  • Update API docs (Swagger/Postman)
  • Mention roles/permissions if required

🔒 Security

  • Middleware for admin authorization
  • Sanitize input data
  • Use HTTPS and CORS as needed

Labels: backend, CRUD, user-service, admin, enhancement
Priority: 🔴 High

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions