graphql: Add a method to delete a group

This commit is contained in:
Valentin Tolmer
2021-09-24 17:35:46 +02:00
committed by nitnelave
parent 402ef2f83a
commit 3b70762b42
5 changed files with 21 additions and 0 deletions

View File

@@ -131,4 +131,12 @@ impl<Handler: BackendHandler + Sync> Mutation<Handler> {
context.handler.delete_user(&user_id).await?;
Ok(Success::new())
}
async fn delete_group(context: &Context<Handler>, group_id: i32) -> FieldResult<Success> {
if !context.validation_result.is_admin {
return Err("Unauthorized group deletion".into());
}
context.handler.delete_group(GroupId(group_id)).await?;
Ok(Success::new())
}
}