mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
rename guard -> mcaptcha
This commit is contained in:
@@ -70,7 +70,7 @@ async fn update_duration(
|
||||
} else {
|
||||
// when mCaptcha/mCaptcha #2 is fixed, this wont be necessary
|
||||
Err(ServiceError::CaptchaError(
|
||||
m_captcha::errors::CaptchaError::CaptchaDurationZero,
|
||||
libmcaptcha::errors::CaptchaError::CaptchaDurationZero,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
use actix_identity::Identity;
|
||||
use actix_web::{web, HttpResponse, Responder};
|
||||
use log::debug;
|
||||
use m_captcha::{defense::Level, DefenseBuilder};
|
||||
use libmcaptcha::{defense::Level, DefenseBuilder};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::mcaptcha::add_mcaptcha_util;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
use actix::prelude::*;
|
||||
use actix_web::{web, HttpResponse, Responder};
|
||||
use m_captcha::{
|
||||
use libmcaptcha::{
|
||||
defense::LevelBuilder, master::AddSiteBuilder, DefenseBuilder, MCaptchaBuilder,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -85,10 +85,10 @@ pub async fn get_config(
|
||||
None => Err(ServiceError::TokenNotFound),
|
||||
}
|
||||
}
|
||||
/// Call this when [MCaptcha][m_captcha::MCaptcha] is not in master.
|
||||
/// Call this when [MCaptcha][libmcaptcha::MCaptcha] is not in master.
|
||||
///
|
||||
/// This fn gets mcaptcha config from database, builds [Defense][m_captcha::Defense],
|
||||
/// creates [MCaptcha][m_captcha::MCaptcha] and adds it to [Master][m_captcha::Defense]
|
||||
/// This fn gets mcaptcha config from database, builds [Defense][libmcaptcha::Defense],
|
||||
/// creates [MCaptcha][libmcaptcha::MCaptcha] and adds it to [Master][libmcaptcha::Defense]
|
||||
async fn init_mcaptcha(data: &Data, key: &str) -> ServiceResult<()> {
|
||||
// get levels
|
||||
let levels_fut = sqlx::query_as!(
|
||||
@@ -151,7 +151,7 @@ async fn init_mcaptcha(data: &Data, key: &str) -> ServiceResult<()> {
|
||||
mod tests {
|
||||
use actix_web::http::{header, StatusCode};
|
||||
use actix_web::test;
|
||||
use m_captcha::pow::PoWConfig;
|
||||
use libmcaptcha::pow::PoWConfig;
|
||||
|
||||
use super::*;
|
||||
use crate::tests::*;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! PoW Verification module
|
||||
|
||||
use actix_web::{web, HttpResponse, Responder};
|
||||
use m_captcha::pow::Work;
|
||||
use libmcaptcha::pow::Work;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::errors::*;
|
||||
@@ -54,7 +54,7 @@ pub async fn verify_pow(
|
||||
mod tests {
|
||||
use actix_web::http::{header, StatusCode};
|
||||
use actix_web::test;
|
||||
use m_captcha::pow::PoWConfig;
|
||||
use libmcaptcha::pow::PoWConfig;
|
||||
|
||||
use super::*;
|
||||
use crate::api::v1::pow::get_config::GetConfigPayload;
|
||||
@@ -125,7 +125,7 @@ mod tests {
|
||||
format!(
|
||||
"{}",
|
||||
ServiceError::CaptchaError(
|
||||
m_captcha::errors::CaptchaError::StringNotFound
|
||||
libmcaptcha::errors::CaptchaError::StringNotFound
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -137,9 +137,9 @@ mod tests {
|
||||
// .await;
|
||||
// assert_eq!(pow_config_resp.status(), StatusCode::OK);
|
||||
// I'm not checking for errors because changing work.result triggered
|
||||
// InssuficientDifficulty, which is possible becuase m_captcha calculates
|
||||
// InssuficientDifficulty, which is possible becuase libmcaptcha calculates
|
||||
// difficulty with the submitted result. Besides, this endpoint is merely
|
||||
// propagating errors from m_captcha and m_captcha has tests covering the
|
||||
// propagating errors from libmcaptcha and libmcaptcha has tests covering the
|
||||
// pow aspects ¯\_(ツ)_/¯
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! PoW success token module
|
||||
|
||||
use actix_web::{web, HttpResponse, Responder};
|
||||
use m_captcha::cache::messages::VerifyCaptchaResult;
|
||||
use libmcaptcha::cache::messages::VerifyCaptchaResult;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::errors::*;
|
||||
@@ -55,8 +55,8 @@ pub async fn validate_captcha_token(
|
||||
mod tests {
|
||||
use actix_web::http::{header, StatusCode};
|
||||
use actix_web::test;
|
||||
use m_captcha::pow::PoWConfig;
|
||||
use m_captcha::pow::Work;
|
||||
use libmcaptcha::pow::PoWConfig;
|
||||
use libmcaptcha::pow::Work;
|
||||
|
||||
use super::*;
|
||||
use crate::api::v1::pow::get_config::GetConfigPayload;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
use actix::prelude::*;
|
||||
use argon2_creds::{Config, ConfigBuilder, PasswordPolicy};
|
||||
use m_captcha::{
|
||||
use libmcaptcha::{
|
||||
cache::HashCache,
|
||||
master::Master,
|
||||
pow::ConfigBuilder as PoWConfigBuilder,
|
||||
|
||||
@@ -25,7 +25,7 @@ use actix_web::{
|
||||
};
|
||||
use argon2_creds::errors::CredsError;
|
||||
use derive_more::{Display, Error};
|
||||
use m_captcha::errors::CaptchaError;
|
||||
use libmcaptcha::errors::CaptchaError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::ParseError;
|
||||
use validator::ValidationErrors;
|
||||
|
||||
@@ -155,7 +155,7 @@ mod test {
|
||||
assert_eq!(
|
||||
&*crate::SOURCE_FILES_OF_INSTANCE,
|
||||
&format!(
|
||||
"https://github.com/mCaptcha/guard/tree/{}",
|
||||
"https://github.com/mCaptcha/mCaptcha/tree/{}",
|
||||
crate::GIT_COMMIT_HASH
|
||||
)
|
||||
);
|
||||
|
||||
@@ -99,9 +99,9 @@ impl Settings {
|
||||
.expect("Couldn't get the number of CPUs");
|
||||
|
||||
const CURRENT_DIR: &str = "./config/default.toml";
|
||||
const ETC: &str = "/etc/guard/config.toml";
|
||||
const ETC: &str = "/etc/mcaptcha/config.toml";
|
||||
|
||||
if let Ok(path) = env::var("GUARD_CONFIG") {
|
||||
if let Ok(path) = env::var("MCAPTCHA_CONFIG") {
|
||||
s.merge(File::with_name(&path))?;
|
||||
} else if Path::new(CURRENT_DIR).exists() {
|
||||
// merging default config from file
|
||||
@@ -112,7 +112,7 @@ impl Settings {
|
||||
log::warn!("configuration file not found");
|
||||
}
|
||||
|
||||
s.merge(Environment::with_prefix("GUARD").separator("_"))?;
|
||||
s.merge(Environment::with_prefix("MCAPTCHA").separator("_"))?;
|
||||
|
||||
check_url(&s);
|
||||
|
||||
@@ -136,7 +136,7 @@ impl Settings {
|
||||
|
||||
match s.try_into() {
|
||||
Ok(val) => Ok(val),
|
||||
Err(e) => Err(ConfigError::Message(format!("\n\nError: {}. If it says missing fields, then please refer to https://github.com/mCaptcha/guard#configuration to learn more about how guard reads configuration\n\n", e)))?,
|
||||
Err(e) => Err(ConfigError::Message(format!("\n\nError: {}. If it says missing fields, then please refer to https://github.com/mCaptcha/mcaptcha#configuration to learn more about how mcaptcha reads configuration\n\n", e)))?,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ use actix_web::{
|
||||
http::{header, StatusCode},
|
||||
middleware as actix_middleware,
|
||||
};
|
||||
use m_captcha::defense::Level;
|
||||
use libmcaptcha::defense::Level;
|
||||
use serde::Serialize;
|
||||
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user