From a2fb5b4a2c5e66e8ec8c28a1ddb390185deb1cdf Mon Sep 17 00:00:00 2001 From: Bob Sun Date: Wed, 15 Feb 2017 11:26:22 +0800 Subject: [PATCH] check pgpKey before decrypting password --- pass/Controllers/PasswordsViewController.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pass/Controllers/PasswordsViewController.swift b/pass/Controllers/PasswordsViewController.swift index 7062f7c..48b6bff 100644 --- a/pass/Controllers/PasswordsViewController.swift +++ b/pass/Controllers/PasswordsViewController.swift @@ -177,6 +177,12 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV } func copyToPasteboard(from indexPath: IndexPath) { + if Defaults[.pgpKeyID] == nil { + let alert = UIAlertController(title: "Cannot Copy Password", message: "PGP Key is not set. Please set your PGP Key first.", preferredStyle: UIAlertControllerStyle.alert) + alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil)) + self.present(alert, animated: true, completion: nil) + return + } let index = sections[indexPath.section].index + indexPath.row let password: PasswordEntity if searchController.isActive && searchController.searchBar.text != "" { @@ -253,7 +259,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool { if identifier == "showPasswordDetail" { - if Defaults[.pgpKeyID] == "" { + if Defaults[.pgpKeyID] == nil { let alert = UIAlertController(title: "Cannot Show Password", message: "PGP Key is not set. Please set your PGP Key first.", preferredStyle: UIAlertControllerStyle.alert) alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil)) self.present(alert, animated: true, completion: nil)