hngprojects / hng_boilerplate_python_fastapi_web

Apache License 2.0
153 stars 140 forks source link

[FEAT]: Send Organisation Invite Via Email #84

Open willgee9531 opened 1 month ago

willgee9531 commented 1 month ago

Description

Create a system for inviting users to organisations via email with time-limited invitation links, supporting multiple invitations at once.

Authentication and Authorization

Acceptance Criteria

Data Validation and Sanitization:

Purpose

Expected Outcome

API Endpoints

1. Send Invitation(s) [POST] /api/v1/organisations/send-invite

Request Headers: Authorization: Bearer

Request Body:

{
  "emails": ["user1@example.com", "user2@example.com", "user3@example.com"],
  "org_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

Success Response (201 Created):

Content-Type: application/json

{
"message": "Invitation(s) sent successfully",
"invitations": [
{
"email": "user1@example.com",
"organization": "My Organization",
"expires_at": "2023-07-23T00:00:00Z"
},
{
"email": "user2@example.com",
"organization": "My Organization",
"expires_at": "2023-07-23T00:00:00Z"
},
{
"email": "user3@example.com",
"organization": "My Organization",
"expires_at": "2023-07-23T00:00:00Z"
}
]
}

Failure Response (400 Bad Request): Content-Type: application/json

{
"error": "Invalid request",
"message": "One or more email addresses are not valid"
}

Failure Response (403 Forbidden): Content-Type: application/json

{
"error": "Unauthorized",
"message": "You do not have admin rights for this organization"
}

Error Handling

Requirements

Testing

willgee9531 commented 1 month ago

Slack-Id:

Will-Gee