Added captcha to booking form. Deleted useless files.
This commit is contained in:
@@ -214,7 +214,7 @@ pub fn is_reserved(reservations: &Vec<Reservation>, time: &NaiveTime, property:
|
||||
}
|
||||
|
||||
#[server]
|
||||
pub async fn create_reservation(reservation: CrReservation) -> Result<ApiResponse<NaiveDate>, ServerFnError> {
|
||||
pub async fn create_reservation(reservation: CrReservation, pow: String) -> Result<ApiResponse<NaiveDate>, ServerFnError> {
|
||||
use crate::backend::get_pool;
|
||||
use crate::backend::customer::find_customer_by_email;
|
||||
use crate::backend::customer::sync_customer_data;
|
||||
@@ -226,6 +226,9 @@ pub async fn create_reservation(reservation: CrReservation) -> Result<ApiRespons
|
||||
use chrono::Local;
|
||||
use sqlx::query;
|
||||
use rust_decimal::Decimal;
|
||||
use leptos_captcha::spow::pow::Pow;
|
||||
|
||||
Pow::validate(&pow)?;
|
||||
|
||||
let slots = reservation.slots().iter().fold(HashMap::new(), |mut map, s| {
|
||||
let slot_str = s.split("|").collect::<Vec<_>>();
|
||||
|
||||
@@ -306,4 +306,11 @@ pub async fn delete_user(id: i32) -> Result<ApiResponse<()>, ServerFnError> {
|
||||
info!("User deleted");
|
||||
|
||||
Ok(ApiResponse::Data(()))
|
||||
}
|
||||
|
||||
#[server]
|
||||
pub async fn get_pow() -> Result<String, ServerFnError> {
|
||||
use leptos_captcha::spow::pow::Pow;
|
||||
|
||||
Ok(Pow::new(10)?.to_string())
|
||||
}
|
||||
Reference in New Issue
Block a user