graphql: Add a method to delete a group
This commit is contained in:
committed by
nitnelave
parent
402ef2f83a
commit
3b70762b42
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ mockall::mock! {
|
||||
async fn update_user(&self, request: UpdateUserRequest) -> DomainResult<()>;
|
||||
async fn delete_user(&self, user_id: &str) -> DomainResult<()>;
|
||||
async fn create_group(&self, group_name: &str) -> DomainResult<GroupId>;
|
||||
async fn delete_group(&self, group_id: GroupId) -> DomainResult<()>;
|
||||
async fn add_user_to_group(&self, user_id: &str, group_id: GroupId) -> DomainResult<()>;
|
||||
async fn remove_user_from_group(&self, user_id: &str, group_id: GroupId) -> DomainResult<()>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user