Switch to async Rust and break all logic.

This commit is contained in:
Paul Makles
2020-12-27 13:28:37 +00:00
parent 5711986768
commit 6cfec0ee08
26 changed files with 1141 additions and 1256 deletions

View File

@@ -1,6 +1,6 @@
use crate::util::variables::{HCAPTCHA_KEY, USE_HCAPTCHA};
use reqwest::blocking::Client;
use reqwest::Client;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
@@ -9,7 +9,7 @@ struct CaptchaResponse {
success: bool,
}
pub fn verify(user_token: &Option<String>) -> Result<(), String> {
pub async fn verify(user_token: &Option<String>) -> Result<(), String> {
if *USE_HCAPTCHA {
if let Some(token) = user_token {
let mut map = HashMap::new();
@@ -21,9 +21,11 @@ pub fn verify(user_token: &Option<String>) -> Result<(), String> {
.post("https://hcaptcha.com/siteverify")
.form(&map)
.send()
.await
{
let result: CaptchaResponse = response
.json()
.await
.map_err(|_| "Failed to deserialise captcha result.".to_string())?;
if result.success {

View File

@@ -1,5 +1,5 @@
use hashbrown::HashSet;
use rand::{distributions::Alphanumeric, Rng};
use std::collections::HashSet;
use std::iter::FromIterator;
pub mod captcha;