model: remove CreateUserRequest

This commit is contained in:
Valentin Tolmer 2021-08-31 15:51:55 +02:00 committed by nitnelave
parent 0dd05e5771
commit 0bcabc7d0c
5 changed files with 21 additions and 20 deletions

View File

@ -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<String>,
pub first_name: Option<String>,
pub last_name: Option<String>,
}
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone, Default)] #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone, Default)]
pub struct DeleteUserRequest { pub struct DeleteUserRequest {
pub user_id: String, pub user_id: String,

View File

@ -3,9 +3,7 @@ use async_trait::async_trait;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashSet; use std::collections::HashSet;
pub use lldap_model::{ pub use lldap_model::{AddUserToGroupRequest, CreateGroupRequest, DeleteUserRequest, Group, User};
AddUserToGroupRequest, CreateGroupRequest, CreateUserRequest, DeleteUserRequest, Group, User,
};
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)] #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
pub struct BindRequest { pub struct BindRequest {
@ -21,6 +19,16 @@ pub enum RequestFilter {
Equality(String, String), 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<String>,
pub first_name: Option<String>,
pub last_name: Option<String>,
}
#[async_trait] #[async_trait]
pub trait LoginHandler: Clone + Send { pub trait LoginHandler: Clone + Send {
async fn bind(&self, request: BindRequest) -> Result<()>; async fn bind(&self, request: BindRequest) -> Result<()>;

View File

@ -249,11 +249,12 @@ mod tests {
use super::*; use super::*;
use crate::{ use crate::{
domain::{ 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}, infra::configuration::{Configuration, ConfigurationBuilder},
}; };
use lldap_model::*;
fn get_default_config() -> Configuration { fn get_default_config() -> Configuration {
ConfigurationBuilder::default() ConfigurationBuilder::default()

View File

@ -1,4 +1,4 @@
use crate::domain::handler::BackendHandler; use crate::domain::handler::{BackendHandler, CreateUserRequest};
use juniper::{graphql_object, FieldResult, GraphQLInputObject}; use juniper::{graphql_object, FieldResult, GraphQLInputObject};
use super::api::Context; use super::api::Context;
@ -38,7 +38,7 @@ impl<Handler: BackendHandler + Sync> Mutation<Handler> {
} }
context context
.handler .handler
.create_user(lldap_model::CreateUserRequest { .create_user(CreateUserRequest {
user_id: user.id.clone(), user_id: user.id.clone(),
email: user.email, email: user.email,
display_name: user.display_name, display_name: user.display_name,

View File

@ -3,8 +3,10 @@
use crate::{ use crate::{
domain::{ domain::{
handler::BackendHandler, sql_backend_handler::SqlBackendHandler, handler::{BackendHandler, CreateUserRequest},
sql_opaque_handler::register_password, sql_tables::PoolOptions, sql_backend_handler::SqlBackendHandler,
sql_opaque_handler::register_password,
sql_tables::PoolOptions,
}, },
infra::{cli::*, configuration::Configuration, db_cleaner::Scheduler}, infra::{cli::*, configuration::Configuration, db_cleaner::Scheduler},
}; };
@ -18,7 +20,7 @@ mod infra;
async fn create_admin_user(handler: &SqlBackendHandler, config: &Configuration) -> Result<()> { async fn create_admin_user(handler: &SqlBackendHandler, config: &Configuration) -> Result<()> {
handler handler
.create_user(lldap_model::CreateUserRequest { .create_user(CreateUserRequest {
user_id: config.ldap_user_dn.clone(), user_id: config.ldap_user_dn.clone(),
..Default::default() ..Default::default()
}) })