feat: update novice captcha creation form to include publish_benchmarks
preference
This commit is contained in:
parent
2cf5e48d8e
commit
2b82af9a0c
5 changed files with 27 additions and 5 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1724,6 +1724,7 @@ dependencies = [
|
||||||
"tokio",
|
"tokio",
|
||||||
"url",
|
"url",
|
||||||
"urlencoding",
|
"urlencoding",
|
||||||
|
"uuid",
|
||||||
"validator",
|
"validator",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,7 @@ lettre = { version = "0.10.0-rc.3", features = [
|
||||||
]}
|
]}
|
||||||
|
|
||||||
openssl = { version = "0.10.48", features = ["vendored"] }
|
openssl = { version = "0.10.48", features = ["vendored"] }
|
||||||
|
uuid = { version = "1.4.0", features = ["v4", "serde"] }
|
||||||
|
|
||||||
|
|
||||||
[dependencies.db-core]
|
[dependencies.db-core]
|
||||||
|
|
|
@ -83,7 +83,11 @@ impl SystemGroup {
|
||||||
enum_system_wrapper!(get_pow, String, CaptchaResult<Option<PoWConfig>>);
|
enum_system_wrapper!(get_pow, String, CaptchaResult<Option<PoWConfig>>);
|
||||||
|
|
||||||
// utility function to verify [Work]
|
// utility function to verify [Work]
|
||||||
pub async fn verify_pow(&self, msg: Work, ip: String) -> CaptchaResult<String> {
|
pub async fn verify_pow(
|
||||||
|
&self,
|
||||||
|
msg: Work,
|
||||||
|
ip: String,
|
||||||
|
) -> CaptchaResult<(String, u32)> {
|
||||||
match self {
|
match self {
|
||||||
Self::Embedded(val) => val.verify_pow(msg, ip).await,
|
Self::Embedded(val) => val.verify_pow(msg, ip).await,
|
||||||
Self::Redis(val) => val.verify_pow(msg, ip).await,
|
Self::Redis(val) => val.verify_pow(msg, ip).await,
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
|
||||||
<label class="sitekey-form__label" for="avg_traffic">
|
<label class="sitekey-form__label" for="avg_traffic">
|
||||||
Average Traffic of your website
|
Average Traffic of your website
|
||||||
<input
|
<input
|
||||||
|
@ -38,7 +39,6 @@
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<label class="sitekey-form__label" for="avg_traffic">
|
<label class="sitekey-form__label" for="avg_traffic">
|
||||||
Maximum traffic that your website can handle
|
Maximum traffic that your website can handle
|
||||||
<input
|
<input
|
||||||
|
@ -68,5 +68,17 @@
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
|
||||||
|
<label class="sitekey-form__label" for="publish_benchmarks">
|
||||||
|
Anonymously publish CAPTCHA performance statistics to help other webmasters
|
||||||
|
<input
|
||||||
|
class="sitekey-form__input"
|
||||||
|
type="checkbox"
|
||||||
|
name="publish_benchmarks"
|
||||||
|
id="publish_benchmarks"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
|
||||||
<button class="sitekey-form__submit" type="submit">Submit</button>
|
<button class="sitekey-form__submit" type="submit">Submit</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -42,6 +42,7 @@ type TrafficPattern = {
|
||||||
peak_sustainable_traffic: number;
|
peak_sustainable_traffic: number;
|
||||||
broke_my_site_traffic?: number;
|
broke_my_site_traffic?: number;
|
||||||
description: string;
|
description: string;
|
||||||
|
publish_benchmarks: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const validate = (e: Event): TrafficPattern => {
|
export const validate = (e: Event): TrafficPattern => {
|
||||||
|
@ -49,9 +50,7 @@ export const validate = (e: Event): TrafficPattern => {
|
||||||
|
|
||||||
let broke_is_set = false;
|
let broke_is_set = false;
|
||||||
|
|
||||||
const AVG_TRAFFIC = <HTMLInputElement>(
|
const AVG_TRAFFIC = <HTMLInputElement>FORM.querySelector("#avg_traffic");
|
||||||
FORM.querySelector("#avg_traffic")
|
|
||||||
);
|
|
||||||
const PEAK_TRAFFIC = <HTMLInputElement>(
|
const PEAK_TRAFFIC = <HTMLInputElement>(
|
||||||
FORM.querySelector("#peak_sustainable_traffic")
|
FORM.querySelector("#peak_sustainable_traffic")
|
||||||
);
|
);
|
||||||
|
@ -59,6 +58,10 @@ export const validate = (e: Event): TrafficPattern => {
|
||||||
FORM.querySelector("#broke_my_site_traffic")
|
FORM.querySelector("#broke_my_site_traffic")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const PUBLISH_BENCHMARKS = <HTMLInputElement>(
|
||||||
|
FORM.querySelector("#publish_benchmarks")
|
||||||
|
);
|
||||||
|
|
||||||
isBlankString(AVG_TRAFFIC.value, avg_traffic_name);
|
isBlankString(AVG_TRAFFIC.value, avg_traffic_name);
|
||||||
isBlankString(PEAK_TRAFFIC.value, peak_traffic_name);
|
isBlankString(PEAK_TRAFFIC.value, peak_traffic_name);
|
||||||
|
|
||||||
|
@ -101,6 +104,7 @@ export const validate = (e: Event): TrafficPattern => {
|
||||||
peak_sustainable_traffic,
|
peak_sustainable_traffic,
|
||||||
broke_my_site_traffic,
|
broke_my_site_traffic,
|
||||||
description,
|
description,
|
||||||
|
publish_benchmarks: PUBLISH_BENCHMARKS.checked,
|
||||||
};
|
};
|
||||||
|
|
||||||
return payload;
|
return payload;
|
||||||
|
|
Loading…
Reference in a new issue