From 20f2e22076a4ebb8fd56be53642bcb6b809b89f7 Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Mon, 8 May 2017 21:12:48 +0800 Subject: [PATCH] Fix a bug about remembering pgp passphrase - Do not keep the wrong passphrase --- pass/Controllers/PasswordDetailTableViewController.swift | 2 ++ pass/Controllers/PasswordsViewController.swift | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pass/Controllers/PasswordDetailTableViewController.swift b/pass/Controllers/PasswordDetailTableViewController.swift index 207e6cb..79e2742 100644 --- a/pass/Controllers/PasswordDetailTableViewController.swift +++ b/pass/Controllers/PasswordDetailTableViewController.swift @@ -147,6 +147,8 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni self.password = try self.passwordStore.decrypt(passwordEntity: self.passwordEntity!, requestPGPKeyPassphrase: self.requestPGPKeyPassphrase) } catch { DispatchQueue.main.async { + // remove the wrong passphrase so that users could enter it next time + self.passwordStore.pgpKeyPassphrase = nil let alert = UIAlertController(title: "Cannot Show Password", message: error.localizedDescription, preferredStyle: UIAlertControllerStyle.alert) alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(UIAlertAction) -> Void in self.navigationController!.popViewController(animated: true) diff --git a/pass/Controllers/PasswordsViewController.swift b/pass/Controllers/PasswordsViewController.swift index 8dacbf1..3e284fe 100644 --- a/pass/Controllers/PasswordsViewController.swift +++ b/pass/Controllers/PasswordsViewController.swift @@ -386,7 +386,9 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV } catch { print(error) DispatchQueue.main.async { - Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil) + // remove the wrong passphrase so that users could enter it next time + self.passwordStore.pgpKeyPassphrase = nil + Utils.alert(title: "Cannot Copy Password", message: error.localizedDescription, controller: self, completion: nil) } } }