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

Implement API endpoint that allow a user to join an organisation on invite #172

Open
iamhammyboi19 opened this issue Jul 23, 2024 · 0 comments
Labels

Comments

@iamhammyboi19
Copy link

Description

Create API endpoints that allows a user to join an organization on invite. These endpoints will validate the invitation link and automatically add the user to the specified organization upon successful validation.

Acceptance Criteria

API Endpoint Implementation:

GET Request:

  • The endpoint should be accessible at /invite/accept/{orgId}.
  • The endpoint should accept HTTP GET requests with a token query parameter.

POST Request:

  • The endpoint should be accessible at /api/invite.
  • The endpoint should accept HTTP POST requests.

Data Validation and Sanitization:

  • The API should validate the orgId in the parameter for GET requests and the request payload for POST requests to ensure the invitation link is present and valid.
  • The invitation link should be checked for correctness and validity (e.g., it hasn't expired and belongs to a valid organization).

Adding User to Organization:

  • Upon successful validation of the invitation link, the user should be added to the specified organization.

Response:

GET Request:

  • On success, the API should return a 200 OK status code with a success message.
  • On failure, the API should return a 400 Bad Request status code with appropriate error messages.

POST Request:

  • On success, the API should return a 200 OK status code with a success message.
  • On failure, the API should return a 400 Bad Request status code with appropriate error messages.

Request Example:

GET /invite/accept/{orgId}

POST /api/invite

{
  "invitationLink": "string"
}

Successful Response:

{
  "message": "Invitation accepted, you have been added to the organization",
  "status": 200
}

Error Response:

{
  "message": "Invalid or expired invitation link",
  "errors": [
    "Invalid invitation link format",
    "Expired invitation link",
    "Organization not found"
  ],
  "status_code": 400
}

Purpose

Provides backend services to handle accepting invitation links for users to join an organization, ensuring the link is valid and automatically adding the user to the appropriate organization.

Requiremients

  • Develop server-side logic to handle invitation link submissions for both GET and POST requests.
  • Validate and sanitize incoming invitation link data.
  • Add the user to the specified organization upon successful validation of the invitation link.

Expected Outcome

  • The API endpoints allow users to accept invitation links via a clickable link or through a POST request, ensuring they are added to the appropriate organization.

Status Codes

  • 200: Invitation was successfully accepted, and the user was added to the organization.
  • 400:
    • Invalid invitation link format
    • Expired invitation link
    • Organization not found
  • 500: A server error occurred

Testing

  • Write unit tests to ensure the invitation link endpoints validate input correctly and add users to the organization.
  • Perform load testing to ensure the endpoints can handle multiple requests.
  • Test various scenarios for submitting the invitation link (e.g., valid link, expired link, malformed link, etc.).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants