check pgpKey before decrypting password

This commit is contained in:
Bob Sun 2017-02-15 11:26:22 +08:00
parent 9f4830dc2a
commit a2fb5b4a2c
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4

View file

@ -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)