Add DELETE /family/{id}/user/{user_id} route
This commit is contained in:
@ -169,3 +169,25 @@ pub async fn update_membership(
|
||||
|
||||
Ok(HttpResponse::Accepted().finish())
|
||||
}
|
||||
|
||||
/// Delete a family membership
|
||||
pub async fn delete_membership(
|
||||
f: FamilyInPathWithAdminMembership,
|
||||
path: web::Path<UserIdInPath>,
|
||||
) -> HttpResult {
|
||||
// An admin can not remove his own membership
|
||||
if path.user_id == f.user_id() {
|
||||
return Ok(HttpResponse::Conflict().body("You cannot remove your own membership!"));
|
||||
}
|
||||
|
||||
families_service::remove_membership(f.family_id(), path.user_id).await?;
|
||||
|
||||
log::info!(
|
||||
"User {:?} removed the membership of user {:?} in the family {:?}",
|
||||
f.user_id(),
|
||||
path.user_id,
|
||||
f.family_id()
|
||||
);
|
||||
|
||||
Ok(HttpResponse::Accepted().finish())
|
||||
}
|
||||
|
Reference in New Issue
Block a user