hngprojects / hng_boilerplate_python_fastapi_web

Apache License 2.0
153 stars 136 forks source link

[FEAT]: Deactivate Invitation Link - Backend #41

Open Arnthorny opened 4 months ago

Arnthorny commented 4 months ago

Description

Create an API endpoint to handle the deactivation of invitation links. This endpoint will validate the invitation link and deactivate it to prevent any further use, ensuring the user deactivating the link has proper authorization.

Acceptance Criteria

API Endpoint Implementation:

Data Validation and Sanitization:

Authorization:

Deactivating the Invitation Link:

Response:

Request Example

[PATCH] /api/v1/invite/deactivate

Example Request

{
  "invitation_link": "invite_12345"
}

Successful Response:

{
  "message": "Invitation link has been deactivated",
  "status_code": 200
}

Error Response:

{
  "message": "Validation error",
  "error": "Invalid or expired invitation link",
  "status_code": 400
}
{
  "message": "Validation error",
  "error": "Organization not found",
  "status_code": 400
}
{
  "message": "Forbidden",
  "error": "User is not authorized to deactivate this invitation link",
  "status_code": 403
}

Purpose

Provides a backend service to handle the deactivation of invitation links, ensuring the link cannot be used again once deactivated and that only authorized users can perform this action.

Requirements

Expected Outcome

The API endpoint allows authorized users to deactivate invitation links via the provided link and ensures they cannot be used again.

Status Codes

Testing

Arnthorny commented 4 months ago

Referred from the main Boilerplate repo Issue#193

Slack id: @thedarkel