Overview
CodeJam uses @convex-dev/auth for authentication, providing multiple sign-in methods and session management.Supported Providers
The authentication system supports four providers:Provider Details
GitHub OAuth
GitHub OAuth
OAuth authentication via GitHub accounts. Users can sign in with their GitHub credentials.
- Type: OAuth 2.0
- Scopes: Basic profile information
- User data: name, email, avatar
Google OAuth
Google OAuth
OAuth authentication via Google accounts.
- Type: OAuth 2.0
- Scopes: Profile and email
- User data: name, email, avatar
Password (Email/Password)
Password (Email/Password)
Traditional email and password authentication.
- Type: Credential-based
- Security: Passwords are hashed and never stored in plain text
- Verification: Optional email verification
Anonymous (Guest)
Anonymous (Guest)
Temporary anonymous sessions for users who want to try the platform without signing up.
- Type: Guest sessions
- Limitations: Cannot access social features (friends, battles)
- Conversion: Can upgrade to full account later
Authentication Pattern
getAuthUserId
All authenticated backend functions use the getAuthUserId helper to retrieve the current user:
Return Values
Returns the user ID if authenticated, or
null if not.User Session Management
Heartbeat
The platform tracks user presence with a heartbeat system:lastSeen timestamp.
Anonymous User Restrictions
Anonymous users are restricted from social features:User Schema
Authenticated users are stored in theusers table with the following fields:
Client-Side Usage
Sign In
Sign Out
Check Auth Status
Security Considerations
- Never trust client data: Always use
getAuthUserId(ctx)on the backend to verify authentication - Check anonymous status: Restrict social features for guest users
- Validate permissions: Always verify the user has permission to access/modify data
- Rate limiting: Consider implementing rate limits for sensitive operations
Related APIs
- Users API - User profile and stats
- Social API - Friend requests and social features