diff --git a/model/src/lib.rs b/model/src/lib.rs index 5041042..dad06de 100644 --- a/model/src/lib.rs +++ b/model/src/lib.rs @@ -92,16 +92,6 @@ impl Default for User { } } -#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone, Default)] -pub struct CreateUserRequest { - // Same fields as User, but no creation_date, and with password. - pub user_id: String, - pub email: String, - pub display_name: Option, - pub first_name: Option, - pub last_name: Option, -} - #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone, Default)] pub struct DeleteUserRequest { pub user_id: String, diff --git a/src/domain/handler.rs b/src/domain/handler.rs index 875e180..f1bef91 100644 --- a/src/domain/handler.rs +++ b/src/domain/handler.rs @@ -3,9 +3,7 @@ use async_trait::async_trait; use serde::{Deserialize, Serialize}; use std::collections::HashSet; -pub use lldap_model::{ - AddUserToGroupRequest, CreateGroupRequest, CreateUserRequest, DeleteUserRequest, Group, User, -}; +pub use lldap_model::{AddUserToGroupRequest, CreateGroupRequest, DeleteUserRequest, Group, User}; #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)] pub struct BindRequest { @@ -21,6 +19,16 @@ pub enum RequestFilter { Equality(String, String), } +#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone, Default)] +pub struct CreateUserRequest { + // Same fields as User, but no creation_date, and with password. + pub user_id: String, + pub email: String, + pub display_name: Option, + pub first_name: Option, + pub last_name: Option, +} + #[async_trait] pub trait LoginHandler: Clone + Send { async fn bind(&self, request: BindRequest) -> Result<()>; diff --git a/src/domain/sql_opaque_handler.rs b/src/domain/sql_opaque_handler.rs index 8117c96..332013a 100644 --- a/src/domain/sql_opaque_handler.rs +++ b/src/domain/sql_opaque_handler.rs @@ -249,11 +249,12 @@ mod tests { use super::*; use crate::{ domain::{ - handler::BackendHandler, sql_backend_handler::SqlBackendHandler, sql_tables::init_table, + handler::{BackendHandler, CreateUserRequest}, + sql_backend_handler::SqlBackendHandler, + sql_tables::init_table, }, infra::configuration::{Configuration, ConfigurationBuilder}, }; - use lldap_model::*; fn get_default_config() -> Configuration { ConfigurationBuilder::default() diff --git a/src/infra/graphql/mutation.rs b/src/infra/graphql/mutation.rs index fa8555b..a4f162a 100644 --- a/src/infra/graphql/mutation.rs +++ b/src/infra/graphql/mutation.rs @@ -1,4 +1,4 @@ -use crate::domain::handler::BackendHandler; +use crate::domain::handler::{BackendHandler, CreateUserRequest}; use juniper::{graphql_object, FieldResult, GraphQLInputObject}; use super::api::Context; @@ -38,7 +38,7 @@ impl Mutation { } context .handler - .create_user(lldap_model::CreateUserRequest { + .create_user(CreateUserRequest { user_id: user.id.clone(), email: user.email, display_name: user.display_name, diff --git a/src/main.rs b/src/main.rs index 0ff7373..9000166 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,8 +3,10 @@ use crate::{ domain::{ - handler::BackendHandler, sql_backend_handler::SqlBackendHandler, - sql_opaque_handler::register_password, sql_tables::PoolOptions, + handler::{BackendHandler, CreateUserRequest}, + sql_backend_handler::SqlBackendHandler, + sql_opaque_handler::register_password, + sql_tables::PoolOptions, }, infra::{cli::*, configuration::Configuration, db_cleaner::Scheduler}, }; @@ -18,7 +20,7 @@ mod infra; async fn create_admin_user(handler: &SqlBackendHandler, config: &Configuration) -> Result<()> { handler - .create_user(lldap_model::CreateUserRequest { + .create_user(CreateUserRequest { user_id: config.ldap_user_dn.clone(), ..Default::default() })