Fix fail-safe mechanism for other decryption scenarios

This commit is contained in:
Mingshen Sun 2020-04-18 22:35:17 -07:00
parent 3e114daca1
commit fcc8961e46
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
15 changed files with 153 additions and 100 deletions

View file

@ -80,9 +80,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
super.viewWillAppear(animated)
if self.shouldPopCurrentView {
let alert = UIAlertController(title: "Notice".localize(), message: "PreviousChangesDiscarded.".localize(), preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: {_ in
_ = self.navigationController?.popViewController(animated: true)
}))
alert.addAction(UIAlertAction.okAndPopView(controller: self))
self.present(alert, animated: true, completion: nil)
}
}
@ -99,6 +97,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
do {
let requestPGPKeyPassphrase = Utils.createRequestPGPKeyPassphraseHandler(controller: self)
self.password = try self.passwordStore.decrypt(passwordEntity: passwordEntity, keyID: keyID, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
self.showPassword()
} catch AppError.PgpPrivateKeyNotFound(let key) {
DispatchQueue.main.async {
// alert: cancel or try again
@ -111,7 +110,6 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
self.present(alert, animated: true, completion: nil)
}
return
} catch {
DispatchQueue.main.async {
// alert: cancel or try again
@ -122,10 +120,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
})
self.present(alert, animated: true, completion: nil)
}
return
}
// display password
self.showPassword()
}
}