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