30 lines
1002 B
Rust
30 lines
1002 B
Rust
use actix_web::{error, web, HttpResponse};
|
|
use glob::glob;
|
|
use handlebars::Handlebars;
|
|
use lettre::SmtpTransport;
|
|
use serde_json::json;
|
|
use terminwahl_typen::RequestState;
|
|
|
|
use crate::db::{write::confirm_appointments, Pool};
|
|
|
|
pub async fn confirm_validation_key(
|
|
pool: web::Data<Pool>,
|
|
mailer: web::Data<SmtpTransport>,
|
|
handlebars: web::Data<Handlebars<'_>>,
|
|
validation_key: web::Path<String>,
|
|
) -> Result<HttpResponse, error::Error> {
|
|
let css_path = glob("terminwahl_front/dist/my_bulma_colors*.css")
|
|
.expect("Failed to find css file")
|
|
.next()
|
|
.expect("Failed to find file")
|
|
.expect("Failed to find file");
|
|
let css_file = css_path.file_name().unwrap().to_str();
|
|
let data = json!({
|
|
"css_file" : css_file,
|
|
});
|
|
match confirm_appointments(&pool, &validation_key).await {
|
|
Ok(_) => Ok(HttpResponse::Ok().body(handlebars.render("confirmed.html", &data).unwrap())),
|
|
Err(e) => Err(error::ErrorBadRequest(e)),
|
|
}
|
|
}
|