diff options
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/access.rs | 4 | ||||
| -rw-r--r-- | src/api/login.rs | 5 | ||||
| -rw-r--r-- | src/api/peers.rs | 2 | ||||
| -rw-r--r-- | src/api/users.rs | 8 |
4 files changed, 9 insertions, 10 deletions
diff --git a/src/api/access.rs b/src/api/access.rs index 9e8a018..daa0f14 100644 --- a/src/api/access.rs +++ b/src/api/access.rs @@ -190,7 +190,7 @@ pub(crate) struct Before { } impl Before { - pub(crate) fn of(doc: &impl crate::document::ReadDoc, user: &str) -> Self { + pub(crate) fn of(doc: &(impl crate::document::view::Read + ?Sized), user: &str) -> Self { use crate::access::registry; let existed = registry::exists(doc); Self { @@ -212,7 +212,7 @@ impl Before { /// leaving nobody once they merge; then the users in `--protocol-writers` may do /// everything again (`access::authorize`). pub(crate) fn registry_kept( - doc: &impl crate::document::ReadDoc, + doc: &(impl crate::document::view::Read + ?Sized), path: &[String], before: Before, user: &str, diff --git a/src/api/login.rs b/src/api/login.rs index 02c54a3..e442ea2 100644 --- a/src/api/login.rs +++ b/src/api/login.rs @@ -674,7 +674,7 @@ async fn end(state: &AppState, claims: &Claims, by: &str) -> Result<(), ApiError let until = claims.login_exp.max(claims.session_exp); let recorded = if state.is_ready().await { state - .mutate_doc_for(Some(by.to_owned()), Sign::Protocol, move |doc| { + .mutate_doc_by(Some(by.to_owned()), Sign::Protocol, move |doc| { if !registry::exists(&*doc) { return Ok::<_, ApiError>(false); } @@ -682,7 +682,6 @@ async fn end(state: &AppState, claims: &Claims, by: &str) -> Result<(), ApiError Ok(true) }) .await? - .0 } else { false }; @@ -773,7 +772,7 @@ pub(crate) async fn revoke_tokens(state: &AppState, name: &str, by: &str) -> Res // Issued in this very millisecond: revoked too. let after = state.clock.now_millis().as_u64() + 1; state - .mutate_doc_for(Some(by.to_owned()), Sign::Protocol, move |doc| { + .mutate_doc_by(Some(by.to_owned()), Sign::Protocol, move |doc| { if !registry::exists(&*doc) { return Err(ApiError( StatusCode::CONFLICT, diff --git a/src/api/peers.rs b/src/api/peers.rs index fc203f5..586c32d 100644 --- a/src/api/peers.rs +++ b/src/api/peers.rs @@ -322,7 +322,7 @@ pub(crate) async fn delete_peer( // Named as who asked: rules by path judge the change by them (`access::rules`). let user = user.map(|axum::Extension(user)| user.0); state - .mutate_doc_for( + .mutate_doc_by( user, crate::document::signatures::Sign::Protocol, move |doc| { diff --git a/src/api/users.rs b/src/api/users.rs index cf28ed1..0c41a56 100644 --- a/src/api/users.rs +++ b/src/api/users.rs @@ -132,7 +132,7 @@ fn may_manage(state: &AppState, user: &str, access: &Access) -> Result<(), ApiEr } /// A user's entry as the API shows it: as recorded, with its name. -fn shown(doc: &impl crate::document::ReadDoc, name: &str) -> Option<JsonValue> { +fn shown(doc: &(impl crate::document::view::Read + ?Sized), name: &str) -> Option<JsonValue> { let mut entry = view::read_plain(doc, ®istry::user_path(name)).ok()??; if let Some(object) = entry.as_object_mut() { object.insert("name".to_owned(), json!(name)); @@ -207,7 +207,7 @@ async fn own_key( let adding = line.is_some(); let id_kept = id.clone(); state - .mutate_doc_for(Some(user.to_owned()), Sign::Protocol, move |doc| { + .mutate_doc_by(Some(user.to_owned()), Sign::Protocol, move |doc| { if crate::access::policy::of(&*doc).strict() { return Err(ApiError( StatusCode::CONFLICT, @@ -287,7 +287,7 @@ async fn change( state: &AppState, user: &str, what: String, - f: impl FnOnce(&mut crate::document::Transaction<'_>, &str, u64) -> Result<(), ApiError> + f: impl FnOnce(&mut dyn crate::document::view::Write, &str, u64) -> Result<(), ApiError> + Send + 'static, ) -> Result<(), ApiError> { @@ -298,7 +298,7 @@ async fn change( let writer = user.to_owned(); let since = state.clock.now_millis().as_u64(); state - .mutate_doc_for(Some(user.to_owned()), Sign::Protocol, move |doc| { + .mutate_doc_by(Some(user.to_owned()), Sign::Protocol, move |doc| { if crate::access::policy::of(&*doc).strict() { return Err(ApiError( StatusCode::CONFLICT, |
