Overview
The invitation system enables:- Organization administrators to invite new users
- Assignment of specific roles during invitation
- Secure email-based verification
- Streamlined onboarding for new users
Invitation Lifecycle
Invitations follow a defined lifecycle managed through status transitions:- Pending: Initial state, awaiting response from invitee
- Accepted: Invitee has accepted and joined the organization
- Rejected: Invitee has explicitly declined the invitation
- Expired: Time limit has passed without response
- Revoked: Administrator has canceled the invitation
Creating Invitations
Organization administrators can invite users with a specified role:- Each invitation is tied to a specific organization
- A specific role is assigned
- A secure random token is generated
- Expiration time is set (default: 48 hours)
- Email notifications are automatically sent
Email Notifications
The system sends personalized invitation emails:- Organization details
- Inviterβs name
- Secure invitation link with token
- Clear instructions for accepting or declining
Accepting Invitations
When a user follows the invitation link, the system:- Validates the invitation token
- Checks if the invitation is still pending and not expired
- Verifies the email address matches
- Displays a signup form
- Creates a new user account
- Associates the user with the organization using the assigned role
Rejecting Invitations
Users can explicitly reject invitations by:- Following a βDeclineβ link in the email
- Clicking a reject button in the application interface
Managing Pending Invitations
Organization administrators can view and manage pending invitations:- List all pending invitations
- Resend invitations
- Revoke invitations before theyβre accepted
- Invitee email address
- Timestamp of invitation
- Current status
- Expiration time
Invitation Token Security
The invitation system incorporates multiple security measures:- Unique Tokens: Each invitation has a cryptographically secure random token
- Limited Validity: Tokens expire after a configurable time period
- Single Use: Tokens become invalid after use
- Email Verification: Token must be used with the invited email address
- Organization Context: Each token is tied to a specific organization
Role Validation
The system enforces hierarchical role constraints:- Users can only invite others with roles of lower privilege
- Owners can invite admins, members, and guests
- Admins can invite members and guests
- Members can only invite guests (if allowed)
API Endpoints
The invitation flow is managed through these endpoints:Endpoint | Method | Description |
---|---|---|
/api/invitations/send | POST | Create a new invitation |
/api/invitations/resend | POST | Resend an existing invitation |
/api/invitations/accept | POST | Accept an invitation |
/api/invitations/reject | POST | Reject an invitation |
/api/invitations/list | GET | List all invitations for an organization |
/api/invitations/{id} | GET | Get details of a specific invitation |
Request and Response Examples
Invitation UI Flow
The frontend implements a streamlined invitation flow:- User receives email with invitation link
- User clicks link and is directed to the application
- System validates the invitation token
- New users complete a registration form
- Existing users are prompted to login
- User is redirected to the organization dashboard
Next Steps
- Authentication Overview: Complete authentication system
- JWT Authentication: How token-based authentication works
- Role-Based Access Control: Understanding permission management