fix(owletto-backend): resolve default org when loading social credentials#235
Merged
Conversation
…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.
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
createAuthwas passingorganizationId=nullfor/api/...requests (the resolver only inspects the URL path, which starts with a reserved segment), soresolveLoginProviderCredentialsskipped the DBauth_profileslookup entirely and fell back to env vars./api/auth/sign-in/social.AUTH_DEFAULT_ORGANIZATION_SLUG(resolveDefaultOrganizationId()) when the request doesn't carry an org, and pass that id to bothgetEnabledLoginProviderConfigsandresolveLoginProviderCredentials.Test plan
bun run typecheckresolveLoginProviderCredentialsagainst theapporg returns validclientIdfor github/google/linkedin/twittercurl -s -X POST -H 'content-type: application/json' -d '{"provider":"linkedin","callbackURL":"/"}' https://app.lobu.ai/api/auth/sign-in/socialreturns a redirect (not "Provider not found")https://app.lobu.ai