Documentation

Guides and references

Authentication

Accept Invitation

Team invitation acceptance flow.

Overview

When a team owner or admin invites someone via email, the invitee receives a link to /accept-invitation?token=xxx. This page handles accepting the invitation and joining the team with the invited role (admin or member).

Flow

  1. Owner or admin invites via AdminTeam → Invite (picks role)
  2. POST /api/teams/invite creates invitation, sends email
  3. Invitee clicks link in email → /accept-invitation?token=xxx
  4. If not logged in: redirect to signup/login, then back to accept-invitation
  5. POST /api/teams/accept-invitation validates token, adds user with the invitation role
  6. Redirect to dashboard
Accept invitation — invalid or expired token state

Files

FileDescription
app/accept-invitation/page.tsxAccept invitation page
components/auth/accept-invitation-form.tsxForm component
app/api/teams/invite/route.tsCreate invite, send email
app/api/teams/accept-invitation/route.tsValidate token, add member

Token Expiry

Invitations expire after INVITATION_EXPIRY_DAYS (default 7) from lib/config/constants.ts. Expired tokens show an error message.

Customization

  • Edit accept-invitation-form.tsx for UI changes
  • Adjust INVITATION_EXPIRY_DAYS in constants
  • Customize email template in components/emails/team-invitation.tsx

Next Steps