mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 08:12:24 +00:00
frontend: Add deletion buttons
This commit is contained in:
@@ -95,3 +95,19 @@ pub async fn route_addressbook_restore<AS: AddressbookStore>(
|
||||
None => (StatusCode::CREATED, "Restored").into_response(),
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn route_delete_addressbook<AS: AddressbookStore>(
|
||||
Path((owner, addressbook_id)): Path<(String, String)>,
|
||||
Extension(store): Extension<Arc<AS>>,
|
||||
user: User,
|
||||
) -> Result<Response, rustical_store::Error> {
|
||||
if !user.is_principal(&owner) {
|
||||
return Ok(StatusCode::UNAUTHORIZED.into_response());
|
||||
}
|
||||
|
||||
store
|
||||
.delete_addressbook(&owner, &addressbook_id, true)
|
||||
.await?;
|
||||
|
||||
Ok(Redirect::to(&format!("/frontend/user/{}", user.id)).into_response())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user