Discord Linking Flow - Complete Issue Analysis & Fix
Current Broken Flows
Flow 1: Discord /verify Command → Account Link (PARTIALLY BROKEN)
/verify Command → Account Link (PARTIALLY BROKEN)User in Discord
↓
/verify command
↓
Bot generates code & verification URL: https://aethex.dev/discord-verify?code=ABCDEF
↓
User clicks link, browser opens page
↓
DiscordVerify.tsx auto-submits code
↓
POST /api/discord/verify-code with code + user_id
↓
Server links discord_id to user_id ✅
↓
Returns success response with discord username ✅
↓
**ISSUE: Frontend redirects to /profile/settings (WRONG PAGE)**
↓
Should redirect to: /dashboard?tab=connectionsFlow 2: Dashboard "Link Discord" Button (COMPLETELY BROKEN)
Flow 3: After Session Lost, User Tries Manual Link (FAILS)
Required Fixes
Fix 1: DiscordVerify.tsx Redirect (Line 92)
Fix 2: Session Persistence During OAuth Callback
Fix 3: Verify Discord OAuth Redirect URI
Fix 4: Add Explicit Cookie Setting in OAuth Callback
Complete Fix Implementation
Step 1: Fix DiscordVerify.tsx Redirect
Step 2: Verify Discord OAuth Redirect URI
Step 3: Improve OAuth Callback Error Handling
Step 4: Add Cookie Debugging
Testing the Fixed Flow
Test 1: Discord /verify Command
/verify CommandTest 2: Dashboard Link Button
Test 3: Already Linked
Test 4: Session Persistence
Common Issues & Debugging
Issue: Still Redirected to Login After Linking
Issue: DiscordVerify Shows Wrong Page
Issue: Discord Doesn't Show in Connections List
File Changes Summary
File
Change
Line(s)
Environment Variables Checklist
After Implementing Fixes
PreviousDiscord Linking Fixes - Summary of ChangesNextDiscord OAuth Login Fix - Account Auto-Creation Removed
Last updated
