Skip to content

Commit

Permalink
Merge pull request #253 from ivpn/bugfix/cannot-log-out
Browse files Browse the repository at this point in the history
Cannot log out of IVPN App
  • Loading branch information
jurajhilje authored May 13, 2022
2 parents e75922d + 99013ba commit e8a57c0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion IVPNClient/IVPNClient.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<string>applinks:www.ivpn.net</string>
</array>
<key>com.apple.developer.default-data-protection</key>
<string>NSFileProtectionComplete</string>
<string>NSFileProtectionCompleteUntilFirstUserAuthentication</string>
<key>com.apple.developer.networking.networkextension</key>
<array>
<string>packet-tunnel-provider</string>
Expand Down
16 changes: 16 additions & 0 deletions IVPNClient/Scenes/MainScreen/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class MainViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.accessibilityIdentifier = "mainScreen"
evaluateFirstRun()
initErrorObservers()
initFloatingPanel()
addObservers()
Expand Down Expand Up @@ -266,4 +267,19 @@ class MainViewController: UIViewController {
#endif
}

private func evaluateFirstRun() {
guard UIApplication.shared.isProtectedDataAvailable else {
return
}

if UserDefaults.standard.object(forKey: UserDefaults.Key.firstInstall) == nil && UserDefaults.standard.object(forKey: UserDefaults.Key.selectedServerGateway) == nil {
KeyChain.clearAll()
UserDefaults.clearSession()
Application.shared.settings.connectionProtocol = Config.defaultProtocol
Application.shared.settings.saveConnectionProtocol()
UserDefaults.standard.set(false, forKey: UserDefaults.Key.firstInstall)
UserDefaults.standard.synchronize()
}
}

}
1 change: 1 addition & 0 deletions IVPNClient/Utilities/Extensions/UserDefaults+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ extension UserDefaults {
static let selectedExitServerRandom = "SelectedExitServerRandom"
static let fastestServerPreferred = "FastestServerPreferred"
static let fastestServerConfigured = "FastestServerConfiguredForOpenVPN"
static let firstInstall = "FirstInstall"
static let secureDNS = "SecureDNS"
static let serviceStatus = "ServiceStatus"
static let isIPv6 = "isIPv6"
Expand Down

0 comments on commit e8a57c0

Please sign in to comment.