Persist selected OAuth provider on callback so it stops reverting to KamoMail

FixEmailService
Shipped
July 8, 2026 at 9:51 PM UTC
Author
Kamo
Commit
e97fc05

Switching an org to Microsoft 365 (or Google Workspace / Zoho) never stuck: the OAuth callback stored tokens and only flipped status on a pre-existing provider row, never writing provider_type and no-op'ing entirely when the org had no row. The read path then fell back to the hard-coded KAMO_MAIL default, so the settings page reverted. Upsert the org_email_providers row with the provider carried in the OAuth state and mark it ACTIVE. Adds OAuthFlowServiceTest covering the no-row and KamoMail-row cases.

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing