diff options
| author | Emīls <emils@mullvad.net> | 2023-07-17 13:22:36 +0200 |
|---|---|---|
| committer | Emīls <emils@mullvad.net> | 2023-07-17 13:22:36 +0200 |
| commit | a4682ed0cc612172990fa1a5505136745f53947a (patch) | |
| tree | 35e76d51b29d1abb7e441e4bda84acaa0ae7f6eb | |
| parent | 4349b2c40b23edbeccc445239cb81f035911aa53 (diff) | |
| parent | 5df201f1da0bf325046b5d89e0e2ce8dc53847c5 (diff) | |
| download | mullvadvpn-a4682ed0cc612172990fa1a5505136745f53947a.tar.xz mullvadvpn-a4682ed0cc612172990fa1a5505136745f53947a.zip | |
Merge branch 'handle-logged-in-account-no-longer-existing-ios-230'
| -rw-r--r-- | ios/MullvadVPN/TunnelManager/TunnelManager.swift | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/ios/MullvadVPN/TunnelManager/TunnelManager.swift b/ios/MullvadVPN/TunnelManager/TunnelManager.swift index e71093bd70..b950170e36 100644 --- a/ios/MullvadVPN/TunnelManager/TunnelManager.swift +++ b/ios/MullvadVPN/TunnelManager/TunnelManager.swift @@ -1056,13 +1056,37 @@ final class TunnelManager: StorePaymentObserver { isPolling = false } + private func cancelPollingKeyRotation() { + guard isRunningPeriodicPrivateKeyRotation else { return } + + logger.debug("Cancel key rotation polling.") + + privateKeyRotationTimer?.cancel() + privateKeyRotationTimer = nil + isRunningPeriodicPrivateKeyRotation = false + } + + private func wipeAllUserData() { + do { + try SettingsManager.setLastUsedAccount(nil) + } catch { + logger.error( + error: error, + message: "Failed to delete account data." + ) + } + } + func handleRestError(_ error: Error) { guard let restError = error as? REST.Error else { return } if restError.compareErrorCode(.deviceNotFound) { setDeviceState(.revoked, persist: true) } else if restError.compareErrorCode(.invalidAccount) { - setDeviceState(.loggedOut, persist: true) + setDeviceState(.revoked, persist: true) + cancelPollingTunnelStatus() + cancelPollingKeyRotation() + wipeAllUserData() } } } |
