mirror of
				https://github.com/nitnelave/lldap.git
				synced 2023-04-12 14:25:13 +00:00 
			
		
		
		
	graphql: Add a method to create a group
This commit is contained in:
		
							parent
							
								
									2a97a2aedf
								
							
						
					
					
						commit
						c093189410
					
				@ -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 New Issue
	
	Block a user