Provide info about the iTunes File Sharing
- only when key files are not existed (not downloaded/pasted/imported)
This commit is contained in:
parent
3cde0d954c
commit
6daa84df30
3 changed files with 34 additions and 17 deletions
|
|
@ -40,9 +40,9 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
// Grey out ssh option if ssh_key and ssh_key.pub are not present
|
||||
// Grey out ssh option if ssh_key is not present
|
||||
if let sshLabel = sshLabel {
|
||||
sshLabel.isEnabled = gitSSHKeyExists()
|
||||
sshLabel.isEnabled = passwordStore.gitSSHKeyExists()
|
||||
}
|
||||
}
|
||||
override func viewDidLoad() {
|
||||
|
|
@ -89,7 +89,7 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
authenticationMethod = "Password"
|
||||
} else if cell == authSSHKeyCell {
|
||||
|
||||
if !gitSSHKeyExists() {
|
||||
if !passwordStore.gitSSHKeyExists() {
|
||||
Utils.alert(title: "Cannot Select SSH Key", message: "Please setup SSH key first.", controller: self, completion: nil)
|
||||
authenticationMethod = "Password"
|
||||
} else {
|
||||
|
|
@ -119,15 +119,11 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
}
|
||||
}
|
||||
|
||||
private func gitSSHKeyExists() -> Bool {
|
||||
return FileManager.default.fileExists(atPath: Globals.gitSSHPrivateKeyPath)
|
||||
}
|
||||
|
||||
func showSSHKeyActionSheet() {
|
||||
let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
var urlActionTitle = "Download from URL"
|
||||
var armorActionTitle = "ASCII-Armor Encrypted Key"
|
||||
var fileActionTitle = "Use Uploaded Keys"
|
||||
var fileActionTitle = "Use Imported Keys"
|
||||
|
||||
if Defaults[.gitSSHKeySource] == "url" {
|
||||
urlActionTitle = "✓ \(urlActionTitle)"
|
||||
|
|
@ -146,11 +142,19 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
optionMenu.addAction(urlAction)
|
||||
optionMenu.addAction(armorAction)
|
||||
|
||||
if (gitSSHKeyExists()) {
|
||||
if passwordStore.gitSSHKeyExists() {
|
||||
// might keys updated via iTunes, or downloaded/pasted inside the app
|
||||
let fileAction = UIAlertAction(title: fileActionTitle, style: .default) { _ in
|
||||
Defaults[.gitSSHKeySource] = "file"
|
||||
}
|
||||
optionMenu.addAction(fileAction)
|
||||
} else {
|
||||
let fileAction = UIAlertAction(title: "iTunes File Sharing", style: .default) { _ in
|
||||
let title = "Import via iTunes File Sharing"
|
||||
let message = "Copy your private key from your computer to Pass for iOS with the name \"ssh_key\" (without quotes)."
|
||||
Utils.alert(title: title, message: message, controller: self)
|
||||
}
|
||||
optionMenu.addAction(fileAction)
|
||||
}
|
||||
|
||||
if Defaults[.gitSSHKeySource] != nil {
|
||||
|
|
|
|||
|
|
@ -258,16 +258,11 @@ class SettingsTableViewController: UITableViewController {
|
|||
appDelegate.passcodeLockPresenter = PasscodeLockPresenter(mainWindow: appDelegate.window, configuration: Globals.passcodeConfiguration)
|
||||
}
|
||||
|
||||
func pgpKeyExists() -> Bool {
|
||||
return FileManager.default.fileExists(atPath: Globals.pgpPublicKeyPath) &&
|
||||
FileManager.default.fileExists(atPath: Globals.pgpPrivateKeyPath)
|
||||
}
|
||||
|
||||
func showPGPKeyActionSheet() {
|
||||
let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
var urlActionTitle = "Download from URL"
|
||||
var armorActionTitle = "ASCII-Armor Encrypted Key"
|
||||
var fileActionTitle = "Use Uploaded Keys"
|
||||
var fileActionTitle = "Use Imported Keys"
|
||||
|
||||
if Defaults[.pgpKeySource] == "url" {
|
||||
urlActionTitle = "✓ \(urlActionTitle)"
|
||||
|
|
@ -286,7 +281,7 @@ class SettingsTableViewController: UITableViewController {
|
|||
optionMenu.addAction(urlAction)
|
||||
optionMenu.addAction(armorAction)
|
||||
|
||||
if (pgpKeyExists()) {
|
||||
if passwordStore.pgpKeyExists() {
|
||||
let fileAction = UIAlertAction(title: fileActionTitle, style: .default) { _ in
|
||||
|
||||
SVProgressHUD.setDefaultMaskType(.black)
|
||||
|
|
@ -338,7 +333,15 @@ class SettingsTableViewController: UITableViewController {
|
|||
}
|
||||
|
||||
optionMenu.addAction(fileAction)
|
||||
} else {
|
||||
let fileAction = UIAlertAction(title: "iTunes File Sharing", style: .default) { _ in
|
||||
let title = "Import via iTunes File Sharing"
|
||||
let message = "Copy your public and private key from your computer to Pass for iOS with the name \"gpg_key.pub\" and \"gpg_key\" (without quotes)."
|
||||
Utils.alert(title: title, message: message, controller: self)
|
||||
}
|
||||
optionMenu.addAction(fileAction)
|
||||
}
|
||||
|
||||
|
||||
if Defaults[.pgpKeySource] != nil {
|
||||
let deleteAction = UIAlertAction(title: "Remove PGP Keys", style: .destructive) { _ in
|
||||
|
|
|
|||
|
|
@ -805,4 +805,14 @@ class PasswordStore {
|
|||
Defaults.remove(.gitSSHPrivateKeyURL)
|
||||
Utils.removeKeychain(name: ".gitSSHPrivateKeyPassphrase")
|
||||
}
|
||||
|
||||
func gitSSHKeyExists() -> Bool {
|
||||
let fm = FileManager.default
|
||||
return fm.fileExists(atPath: Globals.gitSSHPrivateKeyPath)
|
||||
}
|
||||
|
||||
func pgpKeyExists() -> Bool {
|
||||
let fm = FileManager.default
|
||||
return fm.fileExists(atPath: Globals.pgpPublicKeyPath) && fm.fileExists(atPath: Globals.pgpPrivateKeyPath)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue