mirror of
https://github.com/lldap/lldap.git
synced 2024-11-25 09:06:03 +00:00
graphql: Add a method to delete a user
This commit is contained in:
parent
9e3315e09f
commit
e8831f607b
2 changed files with 9 additions and 0 deletions
|
@ -8,6 +8,7 @@ type Mutation {
|
|||
updateUser(user: UpdateUserInput!): Success!
|
||||
addUserToGroup(userId: String!, groupId: Int!): Success!
|
||||
removeUserFromGroup(userId: String!, groupId: Int!): Success!
|
||||
deleteUser(userId: String!): Success!
|
||||
}
|
||||
|
||||
type Group {
|
||||
|
|
|
@ -123,4 +123,12 @@ impl<Handler: BackendHandler + Sync> Mutation<Handler> {
|
|||
.await?;
|
||||
Ok(Success::new())
|
||||
}
|
||||
|
||||
async fn delete_user(context: &Context<Handler>, user_id: String) -> FieldResult<Success> {
|
||||
if !context.validation_result.is_admin {
|
||||
return Err("Unauthorized user deletion".into());
|
||||
}
|
||||
context.handler.delete_user(&user_id).await?;
|
||||
Ok(Success::new())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue