From c2562d31d1b79684c3019113d86cc42b01d829a1 Mon Sep 17 00:00:00 2001 From: Bob Sun Date: Mon, 1 May 2017 23:06:39 -0400 Subject: [PATCH] Give an default authentication method to avoid crashes --- .../GitServerSettingTableViewController.swift | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/pass/Controllers/GitServerSettingTableViewController.swift b/pass/Controllers/GitServerSettingTableViewController.swift index 8843ce7..c8560e1 100644 --- a/pass/Controllers/GitServerSettingTableViewController.swift +++ b/pass/Controllers/GitServerSettingTableViewController.swift @@ -19,7 +19,7 @@ class GitServerSettingTableViewController: UITableViewController { let passwordStore = PasswordStore.shared var sshLabel: UILabel? = nil - var authenticationMethod = Defaults[.gitAuthenticationMethod] + var authenticationMethod = Defaults[.gitAuthenticationMethod] ?? "Password" private func checkAuthenticationMethod(method: String) { let passwordCheckView = authPasswordCell.viewWithTag(1001)! @@ -51,9 +51,8 @@ class GitServerSettingTableViewController: UITableViewController { gitURLTextField.text = url.absoluteString } usernameTextField.text = Defaults[.gitUsername] - authenticationMethod = Defaults[.gitAuthenticationMethod] - checkAuthenticationMethod(method: authenticationMethod!) + checkAuthenticationMethod(method: authenticationMethod) authSSHKeyCell.accessoryType = .detailButton } @@ -80,10 +79,6 @@ class GitServerSettingTableViewController: UITableViewController { Utils.alert(title: "Cannot Save", message: "Git Server is not set.", controller: self, completion: nil) return false } - guard authenticationMethod != nil else { - Utils.alert(title: "Cannot Save", message: "Authentication method is not set.", controller: self, completion: nil) - return false - } } return true } @@ -101,7 +96,7 @@ class GitServerSettingTableViewController: UITableViewController { authenticationMethod = "SSH Key" } } - checkAuthenticationMethod(method: authenticationMethod!) + checkAuthenticationMethod(method: authenticationMethod) tableView.deselectRow(at: indexPath, animated: true) }