Phase 3: The Switchover - Quick Start
Status: ✅ IMPLEMENTATION COMPLETE
The Phase 3 implementation is complete and ready for deployment. aethex.dev is now configured to act as an OAuth client of aethex.foundation, making Foundation the single source of truth for user identity.
What You Need To Know
Before Foundation Migrate
aethex.dev handled all authentication (Discord OAuth, email/password)
User identity was distributed across multiple systems
Each application had its own auth logic
After Phase 3 Deployed
aethex.foundation is the authoritative identity provider
aethex.dev redirects users to Foundation for authentication
All Discord connections handled by Foundation
User profiles synchronized from Foundation to aethex.dev
Quick Setup
Step 1: Set Environment Variables
Add to your .env or deployment configuration:
Note: The FOUNDATION_OAUTH_CLIENT_SECRET will be provided after Foundation's Phase 1 setup is complete.
Step 2: Deploy Phase 3 Code
The following files are new and handle Foundation OAuth:
Client-side:
code/client/lib/foundation-oauth.ts- OAuth flowcode/client/lib/foundation-auth.ts- Token managementcode/client/hooks/use-foundation-auth.ts- React hookscode/client/pages/Login.tsx- UPDATED with Foundation button
Server-side:
code/api/auth/foundation-callback.ts- OAuth callback handlercode/api/auth/exchange-token.ts- Token exchange endpoint
Step 3: Test the Flow
Navigate to
https://aethex.dev/loginClick "Login with Foundation" button
You should be redirected to
aethex.foundation/api/oauth/authorizeAfter authentication, redirected back to aethex.dev dashboard
✅ You're authenticated!
Key Changes in This Phase
Login Page
Old: Discord button redirected to local
/api/discord/oauth/startNew: "Login with Foundation" button redirects to
aethex.foundation
Authentication Flow
Old: Local Supabase auth → Discord OAuth locally → Session on aethex.dev
New: Redirect to Foundation → User auth on Foundation → Session on aethex.dev with Foundation token
User Profile
Old: Stored directly in aethex.dev's Supabase
New: Synced from Foundation's Supabase to aethex.dev's local copy
Discord Management
Old: aethex.dev handled all Discord connections
New: Foundation handles all Discord connections; aethex.dev consumes the result
Important Files
New Components (Phase 3 Specific)
Configuration Files
Testing Checklist
Before going live:
See PHASE3-TESTING-PLAN.md for detailed testing procedures.
What Happens to Discord OAuth?
Discord OAuth is now managed entirely by aethex.foundation.
Users no longer click Discord button on aethex.dev
They click "Login with Foundation" on aethex.dev
Foundation handles Discord OAuth if user chooses it
Foundation issues a token to aethex.dev
aethex.dev accepts the token
Result: Simplified Corp-side code, centralized identity management
User Experience After Phase 3
For New Users
Visit aethex.dev/login
See "Login with Foundation" button (primary option)
Click it
Redirected to aethex.foundation to create account or login
After auth, returned to aethex.dev dashboard
Complete onboarding with pre-filled Foundation data
For Existing Users
Existing sessions will be cleared (they had aethex.dev Supabase tokens)
They'll be redirected to login page
They click "Login with Foundation"
Foundation verifies them (Foundation has their data from Phase 2)
They're logged in on aethex.dev with Foundation's token
Experience continues seamlessly
Architecture After Phase 3
Reverting Phase 3 (If Needed)
If critical issues arise:
Revert code:
Restore environment:
Remove VITE_FOUNDATION_URL
Remove FOUNDATION_OAUTH_CLIENT_SECRET
Tell users:
"We've temporarily disabled Foundation integration"
"Please use local login or Discord OAuth"
Keep old endpoints:
Don't delete
/api/discord/oauth/*endpoints yetThey'll still work if code is reverted
Deployment Recommendations
Staging Deployment (First)
Deploy Phase 3 code to staging
Set Foundation OAuth credentials on staging
Test according to
PHASE3-TESTING-PLAN.mdGet team approval
Monitor staging for 24 hours
Production Deployment
Create backup of current auth system
Deploy Phase 3 code gradually (canary deployment if possible)
Set Foundation OAuth credentials in production
Monitor authentication metrics closely
Have rollback plan ready
Communicate with users
Monitoring
Auth success rate (target >99%)
Token exchange time (target <2s)
Error messages in logs
User support tickets
Foundation connectivity
FAQ
Q: Do existing users need to do anything? A: No, but their old sessions will be cleared. They'll be redirected to Foundation login.
Q: What if Foundation is down? A: Users can't login. Have a communication plan ready.
Q: Can I test without Foundation setup? A: Yes, set VITE_FOUNDATION_URL to a test instance with test credentials.
Q: What about API keys and integrations? A: They remain on aethex.dev. Use Foundation tokens for user identification.
Q: How do I get the Foundation OAuth client secret? A: After Foundation's Phase 1 setup, request it from the Foundation admin.
Q: Can users still use email/password to login? A: Only if Foundation supports it. aethex.dev redirects to Foundation for all auth.
Q: What about Discord linking from aethex.dev? A: Users link Discord on Foundation instead. No linking needed on aethex.dev.
Next Steps
Week 1: Setup
✅ Code implemented (DONE)
⏳ Get Foundation OAuth credentials
⏳ Set environment variables
⏳ Deploy to staging
Week 2: Testing
⏳ Test complete auth flow
⏳ Test error scenarios
⏳ Test on multiple browsers
⏳ Load testing if needed
⏳ Get team approval
Week 3: Deployment
⏳ Deploy to production
⏳ Monitor closely for issues
⏳ Document any bugs found
⏳ Communicate with users
Week 4+: Optimization
⏳ Remove old Discord OAuth endpoints
⏳ Optimize token handling
⏳ Update documentation
⏳ Plan Phase 4 features
Documentation
Detailed documentation available:
PHASE3-SWITCHOVER-GUIDE.md- Complete implementation guide with architecture diagramsPHASE3-IMPLEMENTATION-SUMMARY.md- What was changed and whyPHASE3-TESTING-PLAN.md- How to test each scenarioPHASE3-README.md- THIS FILE
Support
If you encounter issues:
Check logs:
Foundation callback logs (Vercel deployment)
Token exchange errors
Profile sync failures
Verify environment:
VITE_FOUNDATION_URL is correct
FOUNDATION_OAUTH_CLIENT_SECRET is correct
Foundation service is running
Test manually:
Use curl to test token endpoint
Check database for user profiles
Inspect cookies in browser
Escalate if needed:
Contact Foundation admin for OAuth issues
Check infrastructure logs
Review network connectivity
Status: ✅ Phase 3 Implementation Complete & Ready for Testing
Once you obtain Foundation OAuth credentials and complete testing, you'll be ready to make aethex.foundation the official identity provider for your Aethex ecosystem.
Questions? See detailed guides in code/docs/PHASE3-* files.
Last updated
