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: refresh invite link #664

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

coderoyalty
Copy link
Contributor

What does the PR do?

This PR refreshes an invitation link.

How should this be manually tested?

It can be manually tested by sending a POST request to /api/v1/organizations/:organisationId/invite/:inviteId/refresh

Success Response

{
  "status_code": 200,
  "data": {
    "id": "string",
    "invite_link": "string",
    "expires_at": "string (ISO 8601 format)"
  },
  "message": "Invitation link refreshed successfully"
}

Error Response

400 Bad Request

{
  "status_code": 400,
  "error": "Bad Request",
  "message": "Invalid invitation ID format" | "Invalid organisation ID format"
}

401 Unauthorized Access

{
  "status_code": 401,
  "error": "Unauthorized",
  "message": "Authentication required"
}

403 Forbidden

{
  "status_code": 403,
  "error": "Forbidden",
  "message": "You do not have permission to refresh invitation links in this organization"
}

404 Not Found (Invitation)

{
  "status_code": 404,
  "error": "Not Found",
  "message": "The invitation with ID ${id} does not exist in this organization"
}

404 Not Found (Organization)

{
  "status_code": 404,
  "error": "Not Found",
  "message": "The organization with ID ${id} does not exist"
}

Tasks

  • Set up an endpoint for refreshing an invitation link
  • Implement OrganizationGuard
  • Authentication and Authorization of organizations/{org-id}/invitations/{invitation-id}/refresh POST endpoint
  • Validate organization ID and invitation ID formats
  • Implement database query to update invitation link
  • Generate secure and unique invitation links
  • Implement error handling for various scenarios

Reference Issue

https://linear.app/team-bingo/issue/BAC2-35/refresh-invite-link-or-193


@Post(':orgId/invite/:inviteId/refresh')
async refreshInvitation(@Param('orgId') orgId: string, @Param('inviteId') inviteId: string) {
if (isUUID(orgId, 4)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation is best handled in the controllers. Service layer is for your bussiness logic

{
status_code: 400,
error: 'Bad Request',
message: 'Invalid organisation ID format',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use constants where possible to make code cleaner and maintainable. Hardcoded strings just leaves room for errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants