Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Reactivate a user #410

Open
Mubaraktoye opened this issue Feb 27, 2025 · 0 comments · May be fixed by #431
Open

[FEAT] Reactivate a user #410

Mubaraktoye opened this issue Feb 27, 2025 · 0 comments · May be fixed by #431
Assignees
Labels

Comments

@Mubaraktoye
Copy link

Mubaraktoye commented Feb 27, 2025

Description
This issue will implement an API endpoint to reactivate a previously deactivated user's account for the admin user. This endpoint will be part of the administration user management. Admin users will be able to reactivate a user using this endpoint.

** Criteria**

  • The endpoint will be accessible at PUT /api/v1/admin/users/{id}.
  • The endpoint will accept HTTP PUT requests with a payload.
  • The endpoint will reactivate a previously deactivated user's account by updating their status to active in the database using the provided user ID.
  • The endpoint will return a 200 OK status code with the updated user's details in the response body.
  • This endpoint will be secured and only accessible to an admin user.

Payload

To reactivate a user, the appropriate account status will be sent as a payload to the endpoint:

{
   "status": "activate"
}

Response

On successful reactivation of the user, the API will return a 200 OK status code. The response body will contain the user details:

{
  "status": "success",
  "status_code": 200,
  "data": {
    "id": 3454,
    "first_name": "string",
    "last_name": "string",
    "email": "string",
    "avatar_url": "string",
    "phone_number": "string",
    "status": "active",
    "created_at": "2023-01-01T12:00:00Z",
    "updated_at": "2023-06-01T12:00:00Z"
  }
}

Validation

  • If the user's ID is missing or invalid, the API will return a 400 Bad Request status code with an appropriate validation error message:

    {
      "status": "unsuccessful",
      "status_code": 400,
      "message": "Valid user ID must be provided"
    }
  • If the user does not exist, the API will return a 404 Not Found status code with an appropriate message:

    {
      "status": "unsuccessful",
      "status_code": 404,
      "message": "User not found"
    }

Purpose

This endpoint will provide admin users with a way to reactivate a previously deactivated user’s account.

Requirements

  • Develop server-side logic to retrieve user details by ID.
  • Securely handle the retrieval and reactivation process while complying with security standards.
  • Ensure the user’s ID is validated and handled correctly.

Expected Outcome

The API endpoint will allow admin users to reactivate a user's account by ID with appropriate validation and security measures.

Tasks

  1. Define the PUT /api/v1/admin/users/{id} route in the server-side application.
  2. Validate that the user’s ID is provided and is in a valid format.
  3. Implement logic to reactivate the user's account in the database using the provided user ID.
  4. Return the updated user details in the response body if the ID is valid and the user exists.
  5. Handle cases where the user’s ID is invalid or the user does not exist, providing appropriate error messages.

Testing

Write unit tests to validate input validation and user reactivation logic.
Write integration tests to ensure end-to-end functionality.
Perform security testing to ensure data protection and compliance.

@Heba-WebDev Heba-WebDev linked a pull request Mar 1, 2025 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants