mirror of
https://github.com/lldap/lldap.git
synced 2024-11-25 09:06:03 +00:00
graphql: Add a method to create a group
This commit is contained in:
parent
8bd1dec180
commit
35ee2834a3
2 changed files with 16 additions and 0 deletions
|
@ -5,6 +5,7 @@ input EqualityConstraint {
|
|||
|
||||
type Mutation {
|
||||
createUser(user: CreateUserInput!): User!
|
||||
createGroup(name: String!): Group!
|
||||
updateUser(user: UpdateUserInput!): Success!
|
||||
updateGroup(group: UpdateGroupInput!): Success!
|
||||
addUserToGroup(userId: String!, groupId: Int!): Success!
|
||||
|
|
|
@ -83,6 +83,21 @@ impl<Handler: BackendHandler + Sync> Mutation<Handler> {
|
|||
.map(Into::into)?)
|
||||
}
|
||||
|
||||
async fn create_group(
|
||||
context: &Context<Handler>,
|
||||
name: String,
|
||||
) -> FieldResult<super::query::Group<Handler>> {
|
||||
if !context.validation_result.is_admin {
|
||||
return Err("Unauthorized group creation".into());
|
||||
}
|
||||
let group_id = context.handler.create_group(&name).await?;
|
||||
Ok(context
|
||||
.handler
|
||||
.get_group_details(group_id)
|
||||
.await
|
||||
.map(Into::into)?)
|
||||
}
|
||||
|
||||
async fn update_user(
|
||||
context: &Context<Handler>,
|
||||
user: UpdateUserInput,
|
||||
|
|
Loading…
Reference in a new issue