diff --git a/src/api/v1/mcaptcha/levels.rs b/src/api/v1/mcaptcha/levels.rs index 3810083b..5d4ed730 100644 --- a/src/api/v1/mcaptcha/levels.rs +++ b/src/api/v1/mcaptcha/levels.rs @@ -53,6 +53,7 @@ pub mod routes { #[derive(Serialize, Deserialize)] pub struct AddLevels { pub levels: Vec, + pub duration: u32, } pub fn services(cfg: &mut web::ServiceConfig) { @@ -103,7 +104,7 @@ async fn add_levels( defense.build()?; - let mcaptcha_config = add_mcaptcha_util(&data, &id).await?; + let mcaptcha_config = add_mcaptcha_util(payload.duration, &data, &id).await?; for level in payload.levels.iter() { let difficulty_factor = level.difficulty_factor as i32; diff --git a/src/api/v1/mcaptcha/mcaptcha.rs b/src/api/v1/mcaptcha/mcaptcha.rs index 36126085..905e7b61 100644 --- a/src/api/v1/mcaptcha/mcaptcha.rs +++ b/src/api/v1/mcaptcha/mcaptcha.rs @@ -88,7 +88,11 @@ pub struct MCaptchaDetails { } // this should be called from within add levels -pub async fn add_mcaptcha_util(data: &Data, id: &Identity) -> ServiceResult { +pub async fn add_mcaptcha_util( + duration: u32, + data: &Data, + id: &Identity, +) -> ServiceResult { let username = id.identity().unwrap(); let mut key; @@ -99,10 +103,11 @@ pub async fn add_mcaptcha_util(data: &Data, id: &Identity) -> ServiceResult ServiceResult, id: Identity) -> ServiceResult { - let resp = add_mcaptcha_util(&data, &id).await?; + let duration = 30; + let resp = add_mcaptcha_util(duration, &data, &id).await?; Ok(HttpResponse::Ok().json(resp)) } diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 39104298..5318e53b 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -188,6 +188,7 @@ pub async fn add_levels_util( let add_level = AddLevels { levels: levels.clone(), + duration: 30, }; // 1. add level