hngprojects / hng_boilerplate_csharp_web

https://api-csharp.boilerplate.hng.tech
Apache License 2.0
78 stars 41 forks source link

[FEAT] User Status Filtering for Organizations - BACKEND #16

Closed droffilc1 closed 1 month ago

droffilc1 commented 1 month ago

Description:
Implement filtering for users in an organization based on their status (members, suspended, left workspace).

Acceptance Criteria:

  1. Filtering:

    • Implement server-side logic to handle filtering users by their status (members, suspended, left workspace).
  2. User Preferences:

    • Store user status details securely in the database.
    • Handle user-specific configurations and preferences related to the filtering process.
  3. Error Handling:

    • Log errors for invalid filter requests.
    • Display clear error messages for invalid inputs.
  4. Security Measures:

    • Use HTTPS for secure data transmission.
    • Validate user input on the server side.

Purpose:
To filter users securely and efficiently, ensuring accurate and safe user management.

Requirements:

Expected Outcome:

Endpoints:

  1. Fetch Users in Organization:

    • Description: Provide a list of users based on filter criteria within a specific organization with pagination support.

    • Endpoint: GET /api/v1/organizations/{organization_id}/users

    • Request Headers:

      • Authorization: Bearer <token> (required)
      • Content-Type: application/json
      • Accept: application/json
    • Request Parameters:

      • status : string (values: members, suspended, left)
      • page: integer (optional, default: 1)
      • limit: integer (optional, default: 10)
    • Request Example:

           GET /api/v1/organizations/123/users?status=members&page=1&limit=10 HTTP/1.1
           Host: example.com
           Authorization: Bearer <token>
           Content-Type: application/json
           Accept: application/json
      

    Response Example:

    • Response (Success):

      • Status Code: 200 OK
      • Response Body:
           {
              "total": "integer",
              "page": "integer",
              "limit": "integer",
              "prev": "string or null",
              "next": "string or null",
              "users": [
                  {
                    "id": "String",
                    "email": "String",
                    "name": "String",
                    "role": "String",
                    "signup_type": "String",
                    "is_active": true,
                    "is_verified": true,
                    "created_at": "Date",
                    "updated_at": "Date",
                    "last_login_at": "Date",
                    "status": "String"
                 }
              ]
            }
      
    • Response (No Users Found):

      • Status Code: 404 Not Found

      • Response Body:

          {
         "message": "No users found",
         "statusCode": 404
         }
        
    • Response (Invalid Status):

      • Status Code: 400 Bad Request

      • Response Body:

        {
         "message": "Invalid status value",
         "statusCode": 400
        }
        
    • Response (Unauthorized):

      • Status Code: 401 Unauthorized

      • Response Body:

        {
         "message": "Unauthorized",
         "statusCode": 401
        }
        
    • Response (Internal Server Error):

      • Status Code: 500 Internal Server Error

      • Response Body:

        {
         "message": "Internal server error",
         "statusCode": 500
        }
        

Tasks:

Testing:

droffilc1 commented 1 month ago

This Issue is linked to the approved issue here