show alert if key url is empty
This commit is contained in:
parent
a62d50abb0
commit
545a5b11bb
2 changed files with 34 additions and 0 deletions
|
|
@ -30,6 +30,22 @@ class PGPKeySettingTableViewController: UITableViewController {
|
||||||
guard pgpPrivateKeyURLTextField.text != nil else {
|
guard pgpPrivateKeyURLTextField.text != nil else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guard URL(string: pgpPublicKeyURLTextField.text!) != nil else {
|
||||||
|
let alertMessage = "Please set Public Key URL first."
|
||||||
|
let alert = UIAlertController(title: "Cannot Save", message: alertMessage, preferredStyle: UIAlertControllerStyle.alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
|
||||||
|
self.present(alert, animated: true, completion: nil)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
guard URL(string: pgpPrivateKeyURLTextField.text!) != nil else {
|
||||||
|
let alertMessage = "Please set Private Key URL first."
|
||||||
|
let alert = UIAlertController(title: "Cannot Save", message: alertMessage, preferredStyle: UIAlertControllerStyle.alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
|
||||||
|
self.present(alert, animated: true, completion: nil)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if URL(string: pgpPublicKeyURLTextField.text!)!.scheme! == "http" &&
|
if URL(string: pgpPublicKeyURLTextField.text!)!.scheme! == "http" &&
|
||||||
URL(string: pgpPrivateKeyURLTextField.text!)!.scheme! == "http" {
|
URL(string: pgpPrivateKeyURLTextField.text!)!.scheme! == "http" {
|
||||||
let alertMessage = "HTTP connection is not supported."
|
let alertMessage = "HTTP connection is not supported."
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
import SwiftyUserDefaults
|
import SwiftyUserDefaults
|
||||||
|
import SVProgressHUD
|
||||||
|
|
||||||
class SSHKeySettingTableViewController: UITableViewController {
|
class SSHKeySettingTableViewController: UITableViewController {
|
||||||
|
|
||||||
|
|
@ -31,6 +32,21 @@ class SSHKeySettingTableViewController: UITableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
func doneButtonTapped(_ sender: UIButton) {
|
func doneButtonTapped(_ sender: UIButton) {
|
||||||
|
guard URL(string: publicKeyURLTextField.text!) != nil else {
|
||||||
|
let alertMessage = "Please set Public Key URL first."
|
||||||
|
let alert = UIAlertController(title: "Cannot Save", message: alertMessage, preferredStyle: UIAlertControllerStyle.alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
|
||||||
|
self.present(alert, animated: true, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard URL(string: privateKeyURLTextField.text!) != nil else {
|
||||||
|
let alertMessage = "Please set Private Key URL first."
|
||||||
|
let alert = UIAlertController(title: "Cannot Save", message: alertMessage, preferredStyle: UIAlertControllerStyle.alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
|
||||||
|
self.present(alert, animated: true, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
Defaults[.gitRepositorySSHPublicKeyURL] = URL(string: publicKeyURLTextField.text!)
|
Defaults[.gitRepositorySSHPublicKeyURL] = URL(string: publicKeyURLTextField.text!)
|
||||||
Defaults[.gitRepositorySSHPrivateKeyURL] = URL(string: privateKeyURLTextField.text!)
|
Defaults[.gitRepositorySSHPrivateKeyURL] = URL(string: privateKeyURLTextField.text!)
|
||||||
Defaults[.gitRepositorySSHPrivateKeyPassphrase] = passphraseTextField.text!
|
Defaults[.gitRepositorySSHPrivateKeyPassphrase] = passphraseTextField.text!
|
||||||
|
|
@ -39,6 +55,8 @@ class SSHKeySettingTableViewController: UITableViewController {
|
||||||
try Data(contentsOf: Defaults[.gitRepositorySSHPublicKeyURL]!).write(to: Globals.sshPublicKeyURL, options: .atomic)
|
try Data(contentsOf: Defaults[.gitRepositorySSHPublicKeyURL]!).write(to: Globals.sshPublicKeyURL, options: .atomic)
|
||||||
try Data(contentsOf: Defaults[.gitRepositorySSHPrivateKeyURL]!).write(to: Globals.sshPrivateKeyURL, options: .atomic)
|
try Data(contentsOf: Defaults[.gitRepositorySSHPrivateKeyURL]!).write(to: Globals.sshPrivateKeyURL, options: .atomic)
|
||||||
} catch {
|
} catch {
|
||||||
|
SVProgressHUD.showError(withStatus: error.localizedDescription)
|
||||||
|
SVProgressHUD.dismiss(withDelay: 1)
|
||||||
print(error)
|
print(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue