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
- Owner or admin invites via Admin → Team → Invite (picks role)
POST /api/teams/invitecreates invitation, sends email- Invitee clicks link in email →
/accept-invitation?token=xxx - If not logged in: redirect to signup/login, then back to accept-invitation
POST /api/teams/accept-invitationvalidates token, adds user with the invitation role- Redirect to dashboard
Files
| File | Description |
|---|---|
app/accept-invitation/page.tsx | Accept invitation page |
components/auth/accept-invitation-form.tsx | Form component |
app/api/teams/invite/route.ts | Create invite, send email |
app/api/teams/accept-invitation/route.ts | Validate 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.tsxfor UI changes - Adjust
INVITATION_EXPIRY_DAYSin constants - Customize email template in
components/emails/team-invitation.tsx
Next Steps
- Teams — Team management overview
- Authentication — Auth flow