feat: update novice captcha creation form to include publish_benchmarks

preference
This commit is contained in:
Aravinth Manivannan 2023-06-30 03:20:57 +05:30
parent 2cf5e48d8e
commit 2b82af9a0c
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88
5 changed files with 27 additions and 5 deletions

1
Cargo.lock generated
View file

@ -1724,6 +1724,7 @@ dependencies = [
"tokio",
"url",
"urlencoding",
"uuid",
"validator",
]

View file

@ -79,6 +79,7 @@ lettre = { version = "0.10.0-rc.3", features = [
]}
openssl = { version = "0.10.48", features = ["vendored"] }
uuid = { version = "1.4.0", features = ["v4", "serde"] }
[dependencies.db-core]

View file

@ -83,7 +83,11 @@ impl SystemGroup {
enum_system_wrapper!(get_pow, String, CaptchaResult<Option<PoWConfig>>);
// 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 {
Self::Embedded(val) => val.verify_pow(msg, ip).await,
Self::Redis(val) => val.verify_pow(msg, ip).await,

View file

@ -23,6 +23,7 @@
/>
</label>
<label class="sitekey-form__label" for="avg_traffic">
Average Traffic of your website
<input
@ -38,7 +39,6 @@
</label>
<label class="sitekey-form__label" for="avg_traffic">
Maximum traffic that your website can handle
<input
@ -68,5 +68,17 @@
/>
</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>
</form>

View file

@ -42,6 +42,7 @@ type TrafficPattern = {
peak_sustainable_traffic: number;
broke_my_site_traffic?: number;
description: string;
publish_benchmarks: boolean;
};
export const validate = (e: Event): TrafficPattern => {
@ -49,9 +50,7 @@ export const validate = (e: Event): TrafficPattern => {
let broke_is_set = false;
const AVG_TRAFFIC = <HTMLInputElement>(
FORM.querySelector("#avg_traffic")
);
const AVG_TRAFFIC = <HTMLInputElement>FORM.querySelector("#avg_traffic");
const PEAK_TRAFFIC = <HTMLInputElement>(
FORM.querySelector("#peak_sustainable_traffic")
);
@ -59,6 +58,10 @@ export const validate = (e: Event): TrafficPattern => {
FORM.querySelector("#broke_my_site_traffic")
);
const PUBLISH_BENCHMARKS = <HTMLInputElement>(
FORM.querySelector("#publish_benchmarks")
);
isBlankString(AVG_TRAFFIC.value, avg_traffic_name);
isBlankString(PEAK_TRAFFIC.value, peak_traffic_name);
@ -101,6 +104,7 @@ export const validate = (e: Event): TrafficPattern => {
peak_sustainable_traffic,
broke_my_site_traffic,
description,
publish_benchmarks: PUBLISH_BENCHMARKS.checked,
};
return payload;