Skip to content

Commit

Permalink
feat(account): update LoginViewController
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Jan 18, 2024
1 parent 75c781c commit 21dc538
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
11 changes: 8 additions & 3 deletions IVPNClient/Managers/NavigationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ class NavigationManager {
return viewController
}

static func getLoginViewController() -> UIViewController {
static func getLoginViewController(showLogoutAlert: Bool = false) -> UIViewController {
let storyBoard = UIStoryboard(name: "Signup", bundle: nil)
let viewController = storyBoard.instantiateViewController(withIdentifier: "loginView")
let navController = storyBoard.instantiateViewController(withIdentifier: "loginView") as? UINavigationController
navController?.modalPresentationStyle = .formSheet

return viewController
if let viewController = navController?.topViewController as? LoginViewController {
viewController.showLogoutAlert = showLogoutAlert
}

return navController!
}

static func getChangePlanViewController() -> UIViewController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,7 @@ extension ControlPanelViewController {
override func sessionStatusNotFound() {
guard !UserDefaults.standard.bool(forKey: "-UITests") else { return }
logOut(deleteSession: false)
showErrorAlert(title: "You are logged out", message: "You have been redirected to the login page to re-enter your credentials.") { [self] _ in
present(NavigationManager.getLoginViewController(), animated: true)
}
present(NavigationManager.getLoginViewController(showLogoutAlert: true), animated: true)
}

override func deleteSessionStart() {
Expand Down
9 changes: 9 additions & 0 deletions IVPNClient/Scenes/Signup/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class LoginViewController: UIViewController {

// MARK: - Properties -

var showLogoutAlert: Bool = false

private lazy var sessionManager: SessionManager = {
let sessionManager = SessionManager()
sessionManager.delegate = self
Expand Down Expand Up @@ -136,6 +138,13 @@ class LoginViewController: UIViewController {
navigationController?.navigationBar.setNeedsLayout()
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if showLogoutAlert {
showErrorAlert(title: "You are logged out", message: "You have been redirected to the login page to re-enter your credentials.")
}
}

// MARK: - Observers -

func addObservers() {
Expand Down

0 comments on commit 21dc538

Please sign in to comment.