summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMojgan <Mojgan.jelodar@codic.se>2023-07-17 11:44:24 +0200
committerMojgan <Mojgan.jelodar@codic.se>2023-07-17 11:44:24 +0200
commit5df201f1da0bf325046b5d89e0e2ce8dc53847c5 (patch)
tree35e76d51b29d1abb7e441e4bda84acaa0ae7f6eb
parent4349b2c40b23edbeccc445239cb81f035911aa53 (diff)
downloadmullvadvpn-5df201f1da0bf325046b5d89e0e2ce8dc53847c5.tar.xz
mullvadvpn-5df201f1da0bf325046b5d89e0e2ce8dc53847c5.zip
Handle logged in account no longer existing
-rw-r--r--ios/MullvadVPN/TunnelManager/TunnelManager.swift26
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()
}
}
}