Skip to content

Commit 85befb6

Browse files
KM-13284 Handle unexpected presentation of PIAWelcomeViewController when already logged in (#204)
1 parent b9aa1d7 commit 85befb6

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

PIA VPN/UI/PIAWelcomeViewController.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,13 @@ public class PIAWelcomeViewController: AutolayoutViewController, WelcomeCompleti
7272
public override func viewDidLoad() {
7373
super.viewDidLoad()
7474

75-
guard !preset.accountProvider.isLoggedIn else {
76-
fatalError("You are already logged in, you might want to Client.database.truncate() to start clean")
75+
if preset.accountProvider.isLoggedIn {
76+
/// If the user is already logged in, this view controller should not have been presented.
77+
/// This can happen due to a race condition.
78+
/// We just dismiss it and it should trigger DashboardViewController's viewWillAppear,
79+
/// which will evaluate isLoggedIn as true and take another path.
80+
self.navigationController?.dismiss(animated: false)
81+
return
7782
}
7883

7984
buttonCancel.isHidden = true

0 commit comments

Comments
 (0)