App-Specific Authentication
Overview
The authentication system has been updated to provide complete isolation between apps. Each app (PromptNow, GrokTalk, NextJS-Base) now has its own separate user pool.
Key Changes
1. User Segregation
- Users must sign up separately for each app
- Email addresses can be reused across different apps
- No shared authentication between apps
2. Database Structure
userstable now includes anappIdfield- Indexes ensure email uniqueness per app:
by_app_email - User profiles remain app-specific
3. Authentication Flow
Sign Up
- User provides email/password on app-specific sign-up page
- System checks if email exists for that specific app
- New user is created with the app's ID
- User profile is created for that app only
Sign In
- User provides credentials
- System verifies user exists for the specific app
- Session is created for that app only
OAuth (GitHub/Google)
- User authenticates with provider
- System checks if user exists for the app
- If new, creates user with app ID
- Creates or updates app-specific profile
Implementation Details
Frontend (PromptNow example)
// components/app-auth-provider.tsx
export function useAppAuth() {
// Handles app-specific authentication
// Automatically sets appId during sign-up
// Checks email uniqueness per app
}Backend Queries
// Get user for specific app
getCurrentUserForApp({ appId: "promptnow" })
// Check if email exists for app
checkEmailForApp({ email: "user@example.com", appId: "promptnow" })Migration
If you have existing users that need to be separated:
cd tools/convex
npx convex run migrations/separateAppUsers:separateUsersByApp '{"dryRun": true}'Benefits
- Complete Isolation: No data leakage between apps
- Independent User Bases: Each app can have different user requirements
- Flexibility: Users can have different profiles/settings per app
- Security: Compromised account in one app doesn't affect others
Considerations
- Users need separate accounts for each app
- No single sign-on between apps
- Email can be reused across apps
- OAuth accounts are app-specific