hngprojects / hng_boilerplate_nestjs

Description
Apache License 2.0
181 stars 105 forks source link

[FEAT]: Send Organisation Invite Via Email #60

Closed willgee9531 closed 2 weeks 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

markessien commented 1 month ago

Split into multiple tickets

willgee9531 commented 1 month ago

Split into multiple tickets

@markessien @buka4rill @prondubuisi We already split into just sending invites to users via email

Shullyd7 commented 1 month ago

You need Mark's approval first

highb33kay commented 1 month ago

No authorization rules and authentication requirements?

Please go into more details regarding validations

highb33kay commented 1 month ago

Your Accpetance criteria states

Admins can send invitations to single or multiple email addresses
Admins can specify which organisation a user can be invited to

I can only see payload for single user invites

willgee9531 commented 1 month ago

@highb33kay all changes have been made.

Shullyd7 commented 1 month ago

Be consistent with using snake case

willgee9531 commented 1 month ago

@highb33kay refactored, thanks

highb33kay commented 1 month ago

@Shullyd7 good to go?

Shullyd7 commented 1 month ago

Good to go