mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-12 02:25:41 +00:00
chore: use local app ctx
This commit is contained in:
@@ -121,13 +121,11 @@ async fn create(
|
||||
let username = id.identity().unwrap();
|
||||
let payload = payload.into_inner();
|
||||
let pattern = (&payload).into();
|
||||
let levels = calculate(
|
||||
&pattern,
|
||||
&crate::SETTINGS.captcha.default_difficulty_strategy,
|
||||
)?;
|
||||
let levels =
|
||||
calculate(&pattern, &data.settings.captcha.default_difficulty_strategy)?;
|
||||
let msg = CreateCaptcha {
|
||||
levels,
|
||||
duration: crate::SETTINGS.captcha.default_difficulty_strategy.duration,
|
||||
duration: data.settings.captcha.default_difficulty_strategy.duration,
|
||||
description: payload.description,
|
||||
};
|
||||
|
||||
@@ -156,14 +154,12 @@ async fn update(
|
||||
let username = id.identity().unwrap();
|
||||
let payload = payload.into_inner();
|
||||
let pattern = (&payload.pattern).into();
|
||||
let levels = calculate(
|
||||
&pattern,
|
||||
&crate::SETTINGS.captcha.default_difficulty_strategy,
|
||||
)?;
|
||||
let levels =
|
||||
calculate(&pattern, &data.settings.captcha.default_difficulty_strategy)?;
|
||||
|
||||
let msg = UpdateCaptcha {
|
||||
levels,
|
||||
duration: crate::SETTINGS.captcha.default_difficulty_strategy.duration,
|
||||
duration: data.settings.captcha.default_difficulty_strategy.duration,
|
||||
description: payload.pattern.description,
|
||||
key: payload.key,
|
||||
};
|
||||
@@ -201,6 +197,7 @@ pub mod tests {
|
||||
#[test]
|
||||
fn easy_configuration_works() {
|
||||
const NAME: &str = "defaultuserconfgworks";
|
||||
let settings = crate::tests::get_settings();
|
||||
|
||||
let mut payload = TrafficPattern {
|
||||
avg_traffic: 100_000,
|
||||
@@ -208,7 +205,7 @@ pub mod tests {
|
||||
broke_my_site_traffic: Some(10_000_000),
|
||||
};
|
||||
|
||||
let strategy = &crate::SETTINGS.captcha.default_difficulty_strategy;
|
||||
let strategy = &settings.captcha.default_difficulty_strategy;
|
||||
let l1 = LevelBuilder::default()
|
||||
.difficulty_factor(strategy.avg_traffic_difficulty)
|
||||
.unwrap()
|
||||
@@ -273,7 +270,7 @@ pub mod tests {
|
||||
const NAME: &str = "defaultuserconfgworks";
|
||||
const PASSWORD: &str = "longpassworddomain";
|
||||
const EMAIL: &str = "defaultuserconfgworks@a.com";
|
||||
let data = crate::data::Data::new().await;
|
||||
let data = crate::tests::get_data().await;
|
||||
let data = &data;
|
||||
|
||||
delete_user(data, NAME).await;
|
||||
@@ -292,7 +289,7 @@ pub mod tests {
|
||||
|
||||
let default_levels = calculate(
|
||||
&(&payload).into(),
|
||||
&crate::SETTINGS.captcha.default_difficulty_strategy,
|
||||
&data.settings.captcha.default_difficulty_strategy,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -331,7 +328,7 @@ pub mod tests {
|
||||
|
||||
let updated_default_values = calculate(
|
||||
&(&update_pattern).into(),
|
||||
&crate::SETTINGS.captcha.default_difficulty_strategy,
|
||||
&data.settings.captcha.default_difficulty_strategy,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
use actix_identity::Identity;
|
||||
use actix_web::{web, HttpResponse, Responder};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -41,7 +41,7 @@ pub async fn level_routes_work() {
|
||||
const NAME: &str = "testuserlevelroutes";
|
||||
const PASSWORD: &str = "longpassworddomain";
|
||||
const EMAIL: &str = "testuserlevelrouts@a.com";
|
||||
let data = crate::data::Data::new().await;
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
|
||||
delete_user(data, NAME).await;
|
||||
|
||||
@@ -159,7 +159,7 @@ mod tests {
|
||||
const NAME: &str = "updateusermcaptcha";
|
||||
const PASSWORD: &str = "longpassworddomain";
|
||||
const EMAIL: &str = "testupdateusermcaptcha@a.com";
|
||||
let data = crate::data::Data::new().await;
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
delete_user(data, NAME).await;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user