Authentication Controller
The Authentication Controller provides secure user registration, login, profile management, and session handling for the VChata platform.Base Path
Endpoints
Sign Up
- Validates email uniqueness across the platform
- Creates user with encrypted password
- Automatically creates an organization
- Creates Stripe customer and attaches payment method
- Assigns the user as organization admin
- Sets long-lived auth token (7 days) as secure httpOnly cookie
Payment Required: A valid payment method ID from PaymentElement is required for account activation.
Login
- Auth Token: Valid for 7 days, stored in secure httpOnly cookie
- Cookie is automatically sent with all requests
- No Authorization headers needed - cookies handle authentication
- No refresh needed - long-lived token eliminates complexity
Get Current User
- User profile information
- All organization memberships with roles
- Current active organization context
- Platform permissions and settings
Update User Profile
Important: Email updates will require re-verification (not implemented in this endpoint). All fields are optional - only provided fields will be updated.
Logout
Create Setup Intent
Get User Consents
Iframe Debug
- Test iframe detection logic
- Verify cookie settings for different contexts
- Debug authentication issues in iframe environments
- Check CORS and header handling
Error Responses
Common Errors
Security Features
- Secure Cookies: Authentication tokens are stored in httpOnly, secure cookies
- CSRF Protection: Cookie-based authentication provides built-in CSRF protection
- Password Encryption: All passwords are hashed using bcrypt
- Rate Limiting: Login attempts are rate limited to prevent brute force attacks
- JWT Tokens: Secure JWT tokens with 7-day expiration
- Iframe Support: Special handling for iframe contexts with fallback mechanisms
Authentication Flow
1
User Registration
User provides email, password, and payment method
2
Account Creation
System creates user account, organization, and Stripe customer
3
Token Generation
JWT token is generated and set as secure cookie
4
Login
User can login with email/password to receive auth token
5
API Access
All subsequent requests use the auth token for authentication