mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-03-14 13:08:27 +03:00
update and rename captcha plumbing
This commit is contained in:
parent
1b0a95e768
commit
f7c9217667
4 changed files with 94 additions and 37 deletions
85
Cargo.lock
generated
85
Cargo.lock
generated
|
@ -359,9 +359,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ammonia"
|
||||
version = "3.1.1"
|
||||
version = "3.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ee7d6eb157f337c5cedc95ddf17f0cbc36d36eb7763c8e0d1c1aeb3722f6279"
|
||||
checksum = "2e445c26125ff80316eaea16e812d717b147b82a68682bd4730f74d4845c8b35"
|
||||
dependencies = [
|
||||
"html5ever",
|
||||
"lazy_static",
|
||||
|
@ -579,7 +579,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cache-buster"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/realaravinth/cache-buster#8e630d8e4574e2f42d616e4daba425ba33859e59"
|
||||
source = "git+https://github.com/realaravinth/cache-buster#279ba4c7fb6581e81e5af29a36fa7624e256d48a"
|
||||
dependencies = [
|
||||
"data-encoding",
|
||||
"derive_builder",
|
||||
|
@ -593,9 +593,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.68"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787"
|
||||
checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
]
|
||||
|
@ -680,9 +680,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
|
|||
|
||||
[[package]]
|
||||
name = "cookie"
|
||||
version = "0.15.0"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffdf8865bac3d9a3bde5bde9088ca431b11f5d37c7a578b8086af77248b76627"
|
||||
checksum = "d5f1c7727e460397e56abc4bddc1d49e07a1ad78fc98eb2e1c8f032a58a2f80d"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"base64",
|
||||
|
@ -874,13 +874,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "derive_more"
|
||||
version = "0.99.14"
|
||||
version = "0.99.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cc7b9cef1e351660e5443924e4f43ab25fbbed3e9a5f052df3677deb4d6b320"
|
||||
checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustc_version 0.3.3",
|
||||
"syn",
|
||||
]
|
||||
|
||||
|
@ -1360,9 +1361,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.9"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
|
||||
checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
@ -1449,14 +1450,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.97"
|
||||
version = "0.2.98"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"
|
||||
checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790"
|
||||
|
||||
[[package]]
|
||||
name = "libmcaptcha"
|
||||
version = "0.1.4"
|
||||
source = "git+https://github.com/mCaptcha/libmcaptcha?branch=master#60107a2b6f5b1b80c7351a42e05c8c0c6cdbf5de"
|
||||
source = "git+https://github.com/mCaptcha/libmcaptcha?branch=master#22f1a4ccc0a29b5f0fe8437cea1bdc08dc9f4c9b"
|
||||
dependencies = [
|
||||
"actix",
|
||||
"derive_builder",
|
||||
|
@ -1934,6 +1935,15 @@ version = "2.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
|
||||
|
||||
[[package]]
|
||||
name = "pest"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53"
|
||||
dependencies = [
|
||||
"ucd-trie",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf"
|
||||
version = "0.8.0"
|
||||
|
@ -2368,7 +2378,16 @@ version = "0.2.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||
dependencies = [
|
||||
"semver",
|
||||
"semver 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee"
|
||||
dependencies = [
|
||||
"semver 0.11.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2506,7 +2525,16 @@ version = "0.9.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||
dependencies = [
|
||||
"semver-parser",
|
||||
"semver-parser 0.7.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
|
||||
dependencies = [
|
||||
"semver-parser 0.10.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2515,6 +2543,15 @@ version = "0.7.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
|
||||
[[package]]
|
||||
name = "semver-parser"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7"
|
||||
dependencies = [
|
||||
"pest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "0.8.23"
|
||||
|
@ -2591,9 +2628,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "sha-1"
|
||||
version = "0.9.6"
|
||||
version = "0.9.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c4cfa741c5832d0ef7fab46cabed29c2aae926db0b11bb2069edd8db5e64e16"
|
||||
checksum = "1a0c8611594e2ab4ebbf06ec7cbbf0a99450b8570e96cbf5188b5d5f6ef18d81"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"cfg-if 1.0.0",
|
||||
|
@ -2795,7 +2832,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5"
|
||||
dependencies = [
|
||||
"discard",
|
||||
"rustc_version",
|
||||
"rustc_version 0.2.3",
|
||||
"stdweb-derive",
|
||||
"stdweb-internal-macros",
|
||||
"stdweb-internal-runtime",
|
||||
|
@ -2880,9 +2917,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
|||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.4.0"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2"
|
||||
checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
|
@ -3118,6 +3155,12 @@ version = "1.13.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06"
|
||||
|
||||
[[package]]
|
||||
name = "ucd-trie"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.6.0"
|
||||
|
|
|
@ -18,6 +18,7 @@ use std::borrow::Cow;
|
|||
|
||||
use actix_identity::Identity;
|
||||
use actix_web::{web, HttpResponse, Responder};
|
||||
use libmcaptcha::master::messages::RenameBuilder;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::get_random;
|
||||
|
@ -134,9 +135,17 @@ async fn update_token(
|
|||
};
|
||||
}
|
||||
|
||||
let payload = payload.into_inner();
|
||||
let rename = RenameBuilder::default()
|
||||
.name(payload.key)
|
||||
.rename_to(key.clone())
|
||||
.build()
|
||||
.unwrap();
|
||||
data.captcha.rename(rename).await?;
|
||||
|
||||
let resp = MCaptchaDetails {
|
||||
key,
|
||||
name: payload.into_inner().name,
|
||||
name: payload.name,
|
||||
};
|
||||
|
||||
Ok(HttpResponse::Ok().json(resp))
|
||||
|
|
|
@ -141,10 +141,8 @@ async fn init_mcaptcha(data: &AppData, key: &str) -> ServiceResult<()> {
|
|||
.mcaptcha(mcaptcha)
|
||||
.build()
|
||||
.unwrap();
|
||||
match &data.captcha {
|
||||
crate::data::SystemGroup::Embedded(val) => val.master.send(msg).await.unwrap(),
|
||||
crate::data::SystemGroup::Redis(val) => val.master.send(msg).await.unwrap(),
|
||||
};
|
||||
|
||||
data.captcha.add_site(msg).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
29
src/data.rs
29
src/data.rs
|
@ -32,6 +32,7 @@ use libmcaptcha::{
|
|||
cache::messages::VerifyCaptchaResult,
|
||||
cache::Save,
|
||||
errors::CaptchaResult,
|
||||
master::messages::{AddSite, Rename},
|
||||
master::{embedded::master::Master as EmbeddedMaster, Master as MasterTrait},
|
||||
pow::ConfigBuilder as PoWConfigBuilder,
|
||||
pow::PoWConfig,
|
||||
|
@ -81,17 +82,23 @@ impl SystemGroup {
|
|||
}
|
||||
}
|
||||
|
||||
// /// utility function to AddSite
|
||||
// pub async fn add_site(
|
||||
// &self,
|
||||
// msg: AddSite,
|
||||
// ) -> CaptchaResult<()> {
|
||||
// match self {
|
||||
// Self::Embedded(val) => val.master.send(msg).await?,
|
||||
// Self::Redis(val) => val.master.send(msg).await?,
|
||||
// };
|
||||
// Ok(())
|
||||
// }
|
||||
/// utility function to AddSite
|
||||
pub async fn add_site(&self, msg: AddSite) -> CaptchaResult<()> {
|
||||
match self {
|
||||
Self::Embedded(val) => val.master.send(msg).await?,
|
||||
Self::Redis(val) => val.master.send(msg).await?,
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// utility function to rename captcha
|
||||
pub async fn rename(&self, msg: Rename) -> CaptchaResult<()> {
|
||||
match self {
|
||||
Self::Embedded(val) => val.master.send(msg).await?,
|
||||
Self::Redis(val) => val.master.send(msg).await?,
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn new_system<A: Save, B: MasterTrait>(m: Addr<B>, c: Addr<A>) -> System<A, B> {
|
||||
let pow = PoWConfigBuilder::default()
|
||||
|
|
Loading…
Add table
Reference in a new issue