Skip to content

fix(owletto-backend): resolve default org when loading social credentials#235

Merged
buremba merged 1 commit into
mainfrom
fix/auth-default-org-credentials
Apr 20, 2026
Merged

fix(owletto-backend): resolve default org when loading social credentials#235
buremba merged 1 commit into
mainfrom
fix/auth-default-org-credentials

Conversation

@buremba
Copy link
Copy Markdown
Member

@buremba buremba commented Apr 20, 2026

Summary

  • createAuth was passing organizationId=null for /api/... requests (the resolver only inspects the URL path, which starts with a reserved segment), so resolveLoginProviderCredentials skipped the DB auth_profiles lookup entirely and fell back to env vars.
  • LinkedIn/Twitter credentials that live only in the app org's DB were invisible, so Better Auth returned "Provider not found" on /api/auth/sign-in/social.
  • Fix: resolve the default org via AUTH_DEFAULT_ORGANIZATION_SLUG (resolveDefaultOrganizationId()) when the request doesn't carry an org, and pass that id to both getEnabledLoginProviderConfigs and resolveLoginProviderCredentials.

Test plan

  • bun run typecheck
  • Prod DB sanity: running resolveLoginProviderCredentials against the app org returns valid clientId for github/google/linkedin/twitter
  • Post-deploy: curl -s -X POST -H 'content-type: application/json' -d '{"provider":"linkedin","callbackURL":"/"}' https://app.lobu.ai/api/auth/sign-in/social returns a redirect (not "Provider not found")
  • End-to-end LinkedIn login on https://app.lobu.ai

…ials

createAuth was passing organizationId=null for /api/... paths (the
subdomain resolver only reads the URL path), so resolveLoginProviderCredentials
fell back to env vars only and skipped the DB auth_profiles lookup.
LinkedIn/Twitter credentials that live only in the app org's DB were
therefore invisible and Better Auth returned "Provider not found".

Resolve the default org via AUTH_DEFAULT_ORGANIZATION_SLUG when no org
is found on the request, and pass that id to both
getEnabledLoginProviderConfigs and resolveLoginProviderCredentials.
@buremba buremba merged commit 90419cc into main Apr 20, 2026
11 of 12 checks passed
@buremba buremba deleted the fix/auth-default-org-credentials branch April 20, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant