Only delete (address, key) mappings.
- We still want to provide the key material for updates, or revocations. - Fixes #73.
This commit is contained in:
parent
8106d2cec6
commit
ab4f941ac2
|
@ -505,13 +505,12 @@ pub trait Database: Sync + Send {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if fpr = pop-token(tok) {
|
/// Deletes (address, key)-mappings.
|
||||||
// tpk = by_fpr(fpr)
|
///
|
||||||
// for uid in tpk.userids {
|
/// Given a valid deletion token, this function unlinks all email
|
||||||
// del-uid(uid)
|
/// addresses and strips all UserIDs from the stored TPK.
|
||||||
// }
|
///
|
||||||
// del-fpr(fpr)
|
/// Returns true if the token was valid.
|
||||||
// }
|
|
||||||
fn confirm_deletion(&self, token: &str) -> Result<bool> {
|
fn confirm_deletion(&self, token: &str) -> Result<bool> {
|
||||||
let _ = self.lock();
|
let _ = self.lock();
|
||||||
|
|
||||||
|
@ -522,33 +521,8 @@ pub trait Database: Sync + Send {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
loop {
|
self.filter_userids(&fpr, |_| false)?;
|
||||||
match self.by_fpr(&fpr) {
|
Ok(true)
|
||||||
Some(old) => {
|
|
||||||
let tpk = match TPK::from_bytes(old.as_bytes()) {
|
|
||||||
Ok(tpk) => tpk,
|
|
||||||
Err(e) => {
|
|
||||||
return Err(failure::format_err!(
|
|
||||||
"Failed to parse old TPK: {:?}",
|
|
||||||
e));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for uid in tpk.userids() {
|
|
||||||
self.unlink_email(
|
|
||||||
&Email::try_from(uid.userid())?,
|
|
||||||
&fpr,
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.update(&fpr, None)?;
|
|
||||||
return Ok(true);
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
return Ok(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
None => Ok(false),
|
None => Ok(false),
|
||||||
|
|
|
@ -418,7 +418,6 @@ pub fn test_uid_deletion_request<D: Database>(db: &mut D) {
|
||||||
assert!(db.confirm_deletion(&del).unwrap());
|
assert!(db.confirm_deletion(&del).unwrap());
|
||||||
|
|
||||||
// check it's gone
|
// check it's gone
|
||||||
assert!(db.by_fpr(&fpr).is_none());
|
|
||||||
assert!(db.by_email(&email1).is_none());
|
assert!(db.by_email(&email1).is_none());
|
||||||
assert!(db.by_email(&email2).is_none());
|
assert!(db.by_email(&email2).is_none());
|
||||||
|
|
||||||
|
@ -426,7 +425,6 @@ pub fn test_uid_deletion_request<D: Database>(db: &mut D) {
|
||||||
assert!(!db.confirm_deletion(&del).unwrap());
|
assert!(!db.confirm_deletion(&del).unwrap());
|
||||||
|
|
||||||
// check it's still gone
|
// check it's still gone
|
||||||
assert!(db.by_fpr(&fpr).is_none());
|
|
||||||
assert!(db.by_email(&email1).is_none());
|
assert!(db.by_email(&email1).is_none());
|
||||||
assert!(db.by_email(&email2).is_none());
|
assert!(db.by_email(&email2).is_none());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue