feat(auth): add Discord as auth provider with guild membership verification#1354
Merged
evanjacobson merged 19 commits intomainfrom Mar 23, 2026
Merged
Conversation
Add Discord OAuth provider (identify+email) to NextAuth, following the existing GitHub/GitLab/LinkedIn pattern. Includes DB migration for discord_server_member tracking columns, GDPR soft-delete coverage, DiscordLogo component, and provider metadata registration.
Add backend service to check Discord guild membership via Bot API, tRPC routes for querying/verifying status, and DiscordGuildStatus UI component on the Connected Accounts page.
Use DISCORD_OAUTH_CLIENT_ID, DISCORD_OAUTH_CLIENT_SECRET, and DISCORD_OAUTH_BOT_TOKEN for the user-linking OAuth app, keeping the existing DISCORD_* vars untouched for the bot integration.
When a user lands on /connected-accounts with Discord linked but never verified, automatically trigger the guild membership check instead of requiring a manual button click.
…ofile-connect-social-accounts
…useEffect dependency array. The mutate function is referentially stable, so this resolves the @tanstack/query/no-unstable-deps lint error.
…ider ID from response Wrap checkDiscordGuildMembership in try/catch to prevent leaking internal error details (rate limits, missing env vars) to the client. Remove discord_provider_account_id from getDiscordGuildStatus response since the client never uses it.
…ame, clear on unlink - Remove discord_server_member boolean; use discord_server_membership_verified_at timestamp alone (non-null = member, null = not verified/not a member) - Add display_name column to user_auth_provider and store Discord username - Clear discord_server_membership_verified_at when unlinking Discord - Regenerate migration (0057) to reflect new schema
7 tasks
…xception - Remove client-side auto-verify useEffect; verify guild membership server-side during account creation and linking instead - Extract tryVerifyDiscordGuildMembership helper to avoid duplication - Replace console.error with captureException for Discord API errors - Simplify DiscordGuildStatus component to be purely declarative
Contributor
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)No new issues found in the incremental diff. Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments:
Resolved in new commits: the previous Files Reviewed (3 files)
Fix these issues in Kilo Cloud Reviewed by gpt-5.4-20260305 · 533,150 tokens |
… and added an error message when membership check fails
Regenerated drizzle migration as 0058 to resolve collision with 0057_backfill_billing_misclassified from main.
jeanduplessis
approved these changes
Mar 23, 2026
Report caught errors with operation tag and user context instead of silently swallowing them. Also rename migration 0058 for clarity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
discord_server_memberanddiscord_server_member_atcolumns tokilocode_usersVerification
pnpm typecheck— passespnpm test— passesVisual Changes
New "Discord Server Membership" card on the user profile page showing:
Loom (Kilo Team only)
https://www.loom.com/share/3512eb86ef38454d86c95fa7cbfc51f1
Other PRs for this feature
#1356
Reviewer Notes
DISCORD_OAUTH_CLIENT_ID,DISCORD_OAUTH_CLIENT_SECRET) are separate from the existing bot token (DISCORD_OAUTH_BOT_TOKEN) — the bot token is used server-side for guild membership checksdiscord_provider_account_idwas intentionally excluded from thegetDiscordGuildStatusresponse to minimize API surface