Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved session cleanup risks can cause missed identity-change handling, concurrent data deletion, and incomplete cleanup.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds SSO identity tracking and clears retained account data when the identity provider changes.
Changes:
- Persists and propagates SSO identity-provider IDs.
- Adds identity-change confirmation, purge, and restart flows.
- Updates account/session models and related tests.
File summaries
| File | Summary |
|---|---|
WireDomain/Tests/WireDomainTests/Account/AccountStoreTests.swift |
Tests provider-ID persistence. |
WireDomain/Tests/WireDomainTests/Account/AccountManagerTests.swift |
Tests account updates. |
WireDomain/Sources/WireDomain/Account/StoredAccount.swift |
Stores provider ID metadata. |
WireAuthentication/Tests/WireAuthenticationUITests/Views/DetermineAuthMethod/DetermineAuthMethodViewModelTests.swift |
Tests provider-ID propagation. |
WireAuthentication/Tests/WireAuthenticationLogicTests/DetermineAuthMethodUseCaseTests.swift |
Tests SSO discovery metadata. |
WireAuthentication/Sources/WireAuthenticationUI/Views/DetermineAuthMethod/DetermineAuthMethodViewModel.swift |
Carries identity metadata through login. |
WireAuthentication/Sources/WireAuthenticationLogic/DetermineAuthMethodUseCase.swift |
Associates SSO codes with provider IDs. |
WireAuthentication/Sources/WireAuthenticationAPI/Use cases/DetermineAuthMethodUseCaseProtocol.swift |
Extends SSO method data. |
WireAuthentication/Sources/WireAuthenticationAPI/Models/AuthenticationResult.swift |
Adds provider-ID metadata. |
WireAuthentication/Sources/WireAuthentication/WireAuthenticationAssembly.swift |
Updates authentication callbacks. |
WireAuthentication/Sources/WireAuthentication/Components/RootComponent.swift |
Propagates callback changes. |
WireAuthentication/Sources/WireAuthentication/Components/DetermineAuthMethodComponent.swift |
Updates component dependencies. |
wire-ios/Wire-iOS/Sources/Authentication/Helpers/ObservableSessionManager.swift |
Exposes retained-data purging. |
wire-ios/Wire-iOS/Sources/Authentication/Event Handlers/AuthenticationCoordinatorAction.swift |
Adds purge and restart actions. |
wire-ios/Wire-iOS/Sources/Authentication/Coordinator/AuthenticationCoordinator.swift |
Handles identity changes and cleanup. |
wire-ios/Wire-iOS/Sources/Authentication/AuthenticationInterfaceBuilder.swift |
Determines active accounts. |
wire-ios-sync-engine/Tests/Source/UserSession/UnauthenticatedSessionTests.swift |
Tests provider-ID storage. |
wire-ios-sync-engine/Source/UnauthenticatedSession/UnauthenticatedSession.swift |
Stores provider IDs on new accounts. |
wire-ios-sync-engine/Source/SessionManager/SessionManager.swift |
Implements retained-data cleanup. Findings include active-session detection, concurrent deletion, cookie-removal error handling, and missing purge coverage. |
wire-ios-data-model/Source/Model/Account/Account.swift |
Adds persisted account metadata. |
Review details
Suppressed comments (2)
wire-ios-sync-engine/Source/SessionManager/SessionManager.swift:388
environment.isAuthenticatedis true for a retained account whenever its non-expired auth cookie remains. The existing “Log out and keep data” path closes the session withdeleteCookie: false, so this method still returnstrueafter the session is torn down; the SSO callback then reports.alreadyLoggedInand never reaches the identity-change alert/purge for the retained-account scenario. Base this check on loaded-session state (while retaining the active session during teardown) instead of the cookie.
return environment.isAuthenticated(selectedAccount)
}
wire-ios-sync-engine/Source/SessionManager/SessionManager.swift:1184
- The new destructive purge path is not covered by the added tests: there is no test that verifies the account-data folder, cookies, user defaults, and account record are removed, nor that an active account is rejected or a deletion failure is handled. Please add focused SessionManager tests before relying on this flow to prevent partial cleanup or accidental data loss regressions.
}
}
public func purgeRetainedAccountData(for userID: UUID) throws {
guard let account = accountManager.account(with: userID) else { return }
- Files reviewed: 20/20 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| public func isAccountActive(_ account: Account) -> Bool { | ||
| backgroundUserSessions[account.userIdentifier] != nil || environment.isAuthenticated(account) | ||
| } |
| do { | ||
| try environment.cookieStorage(for: account).removeCookies() | ||
| } catch { | ||
| WireLogger.sessionManager.error("Failed to remove cookies: \(error)") | ||
| } |
Test Results – batch 0 2 files 173 suites 27s ⏱️ Results for commit 61ec1ea. |
Test Results – batch 21 141 tests 1 141 ✅ 1m 22s ⏱️ Results for commit 61ec1ea. |
Test Results – batch 14 334 tests 4 307 ✅ 6m 16s ⏱️ Results for commit 61ec1ea. |
Issue
This re-applies changes that were reverted for multi-ingress. All this code in the following commit has been reviewed and approved:
commit 8e40f1b.
It will also include a fix for the case that failed QA previously: a different IdP ID displays the confirmation dialog. A dedicated PR will be done for that.
Testing
N/A
Checklist
[WPB-XXX].UI accessibility checklist
If your PR includes UI changes, please utilize this checklist: