diff --git a/pass/Base.lproj/Main.storyboard b/pass/Base.lproj/Main.storyboard index abf6412..08b8ebf 100644 --- a/pass/Base.lproj/Main.storyboard +++ b/pass/Base.lproj/Main.storyboard @@ -23,11 +23,11 @@ - + - + @@ -81,11 +81,11 @@ - + - + @@ -101,11 +101,11 @@ - + - + @@ -125,18 +125,18 @@ - + - + - + @@ -180,7 +180,7 @@ - + @@ -209,7 +209,7 @@ - + @@ -238,7 +238,7 @@ - + @@ -271,18 +271,18 @@ - + - + - + @@ -343,11 +343,11 @@ - + - + @@ -363,11 +363,11 @@ - + - + @@ -412,7 +412,7 @@ - + @@ -441,7 +441,7 @@ - + @@ -622,7 +622,7 @@ - + @@ -651,7 +651,7 @@ - + @@ -680,7 +680,7 @@ - + diff --git a/pass/GitServerSettingTableViewController.swift b/pass/GitServerSettingTableViewController.swift index e6cc075..6e71d0d 100644 --- a/pass/GitServerSettingTableViewController.swift +++ b/pass/GitServerSettingTableViewController.swift @@ -16,6 +16,9 @@ class GitServerSettingTableViewController: UITableViewController { @IBOutlet weak var passwordTextField: UITextField! @IBOutlet weak var authenticationTableViewCell: UITableViewCell! + var authenticationMethod = "Password" + + override func viewDidLoad() { super.viewDidLoad() if let url = Defaults[.gitRepositoryURL] { @@ -28,19 +31,36 @@ class GitServerSettingTableViewController: UITableViewController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - gitRepositoryURLTextField.becomeFirstResponder() + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + if authenticationMethod == "SSH Key" { + if Defaults[.gitRepositorySSHPublicKeyURL] == nil && Defaults[.gitRepositorySSHPrivateKeyURL] == nil { + authenticationMethod = "Password" + + let alertController = UIAlertController(title: "Attention", message: "Please setup SSH key first.", preferredStyle: .alert) + let defaultAction = UIAlertAction(title: "OK", style: .default, handler: nil) + alertController.addAction(defaultAction) + present(alertController, animated: true, completion: nil) + } else { + authenticationMethod = "SSH Key" + } + } + authenticationTableViewCell.detailTextLabel?.text = authenticationMethod } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) view.endEditing(true) } + @IBAction func save(segue: UIStoryboardSegue) { if let controller = segue.source as? UITableViewController { if controller.tableView.indexPathForSelectedRow == IndexPath(row: 0, section:0) { - authenticationTableViewCell.detailTextLabel?.text = "Password" + authenticationMethod = "Password" } else { - authenticationTableViewCell.detailTextLabel?.text = "SSH Key" + authenticationMethod = "SSH Key" } } }