Skip to main content

Authentication Controller

The Authentication Controller provides secure user registration, login, profile management, and session handling for the VChata platform.

Base Path

Endpoints

Sign Up

Description: Creates a new user account along with an organization. This endpoint:
  • 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.
object

Login

Description: Authenticates a user with email and password using secure cookie-based authentication. Cookie-Based Authentication:
  • 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
object

Get Current User

Description: Retrieves the currently authenticated user’s profile along with their organization memberships. Response includes:
  • User profile information
  • All organization memberships with roles
  • Current active organization context
  • Platform permissions and settings

Update User Profile

Description: Updates the current user’s profile information including first name, last name, nickname, and email.
Important: Email updates will require re-verification (not implemented in this endpoint). All fields are optional - only provided fields will be updated.
object

Logout

Description: Logs out the current user by clearing the authentication cookie and invalidating the session.

Create Setup Intent

Description: Creates a Stripe setup intent for adding or updating payment methods. This is used to securely collect payment method information without processing a charge.

Get User Consents

Description: Retrieves all active consent records for the authenticated user.

Iframe Debug

Description: Debug endpoint to test iframe authentication behavior and cookie settings. Returns information about the request context and cookie configuration. Use this endpoint to:
  • 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