diff options
Diffstat (limited to 'src/access')
| -rw-r--r-- | src/access/rules.rs | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/src/access/rules.rs b/src/access/rules.rs index ac7377f..d8162a6 100644 --- a/src/access/rules.rs +++ b/src/access/rules.rs @@ -279,13 +279,14 @@ pub(crate) fn judge_reading( { true } - // A user's own keys (`/auth/keys`), whatever else it may do, one left at - // least. + // A user's own keys (`/auth/keys`), whatever else it may do; its last too + // (the node it asks keeps that from one without a password there, which no + // other node can tell). (Some(meta::USERS), Some(owner)) if path.get(3).map(String::as_str) == Some("keys") && change.user == Some(owner) => { - keys_left(&at, owner, change.ops) + true } // A node forgotten while alive cancels its own record (`swarm::peer::forget`). (Some(meta::FORGOTTEN), Some(owner)) => owner == node || user_may(path), @@ -531,30 +532,6 @@ fn made_the_epoch(at: &At<'_>, epoch: Epoch, id: &str, node: &str) -> bool { == Some(node) } -/// Whether `owner` has a key left after `ops`, its keys at `at` as they change them. -fn keys_left(at: &At<'_>, owner: &str, ops: &[Op]) -> bool { - let keys = meta::path(&[meta::USERS, owner, "keys"]); - let mut left: BTreeSet<String> = store::keys_at(at, &keys) - .ok() - .flatten() - .unwrap_or_default() - .into_iter() - .collect(); - for op in ops.iter().filter(|op| op.path.starts_with(&keys)) { - match (op.path.get(keys.len()), &op.action) { - (None, _) => left.clear(), - (Some(id), Action::Delete) => { - left.remove(id); - } - (Some(id), _) if op.path.len() == keys.len() + 1 => { - left.insert(id.clone()); - } - _ => {} - } - } - !left.is_empty() -} - /// The coordinator remake `id`'s proposal names, at `at`. fn coordinator(at: &At<'_>, id: &str) -> Option<String> { let proposal = store::read_path(at, &meta::path(&[meta::REMAKES, id, "proposal"])) |
