You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an app uses a Welcome/Discovery domain (e.g., welcome.salesforce.com/discovery) as its login host, the domain discovery flow resolves the user's My Domain and passes it to handleCustomDomainUpdateWithLoginHint:. Previously, this called setLoginHost:, which persisted the My Domain into SFSDKLoginHostStorage and NSUserDefaults. This caused two problems:
The server picker list got polluted with My Domain entries
After logout, the login screen showed the My Domain instead of returning to the Welcome/Discovery page
Changes
SFOAuthCoordinator: Remove setLoginHost: call from handleCustomDomainUpdateWithLoginHint:loginHint: — credentials.domain is sufficient for the auth flow and doesn't pollute persistent storage.
SFUserAccountManager: Skip overwriting loginHost with credentials.domain when the current login host is a discovery domain (checked via DomainDiscoveryCoordinator.isDiscoveryDomain:).
WelcomeDiscoveryLoginHostTests: Add tests covering isDiscoveryDomain logic, login host preservation after setting current user, and verifying storage isn't polluted.
Test Plan
Unit tests pass (WelcomeDiscoveryLoginHostTests)
Configure app with Welcome/Discovery domain → log in → verify login host remains discovery domain
Log out → verify login screen returns to Welcome/Discovery page (not My Domain)
Verify server picker does not accumulate My Domain entries after repeated login/logout cycles
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.20%. Comparing base (36f6bf6) to head (2459542). ⚠️ Report is 8 commits behind head on dev.
LGTM, but before I approve I would like to know how/where the correct (My Domain) url gets saved on the user when they login with Welcome.
@brandonpage In line 870, self.credentials.domain = myDomain; of handleCustomDomainUpdateWithLoginHint:myDomain:, SFOAuthCoordinator holds onto self.credentials from start to finish. When domain discovery resolves mycompany.my.salesforce.com, it's written directly onto that credentials object.
When [self authenticate] is called immediately after, it reads credentials.domain to construct https://mycompany.my.salesforce.com/services/oauth2/authorize?..... No global loginHost needed.
After auth completes, finalizeAuthCompletion: → applyCredentials:withIdData: assigns authSession.oauthCoordinator.credentials (which still carries domain = mycompany.my.salesforce.com) to the user account, then calls saveAccountForUser: which archives it via NSCoding.
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
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
When an app uses a Welcome/Discovery domain (e.g.,
welcome.salesforce.com/discovery) as its login host, the domain discovery flow resolves the user's My Domain and passes it tohandleCustomDomainUpdateWithLoginHint:. Previously, this calledsetLoginHost:, which persisted the My Domain intoSFSDKLoginHostStorageandNSUserDefaults. This caused two problems:Changes
setLoginHost:call fromhandleCustomDomainUpdateWithLoginHint:loginHint:—credentials.domainis sufficient for the auth flow and doesn't pollute persistent storage.loginHostwithcredentials.domainwhen the current login host is a discovery domain (checked viaDomainDiscoveryCoordinator.isDiscoveryDomain:).isDiscoveryDomainlogic, login host preservation after setting current user, and verifying storage isn't polluted.Test Plan
WelcomeDiscoveryLoginHostTests)