log if new kiosk cookie is set

This commit is contained in:
philipp 2023-10-05 08:46:34 +02:00
parent 5539f033f1
commit c47b3bb447

View File

@ -1,3 +1,5 @@
use std::net::IpAddr;
use rocket::{ use rocket::{
form::Form, form::Form,
get, get,
@ -15,6 +17,7 @@ use tera::Context;
use crate::model::{ use crate::model::{
boat::Boat, boat::Boat,
log::Log,
logbook::{ logbook::{
LogToAdd, LogToFinalize, Logbook, LogbookCreateError, LogbookDeleteError, LogToAdd, LogToFinalize, Logbook, LogbookCreateError, LogbookDeleteError,
LogbookUpdateError, LogbookUpdateError,
@ -91,7 +94,17 @@ async fn show_kiosk(db: &State<SqlitePool>, _kiosk: KioskCookie) -> Template {
} }
#[get("/kiosk/ekrv2019/<loc>")] #[get("/kiosk/ekrv2019/<loc>")]
fn new_kiosk(cookies: &CookieJar<'_>, loc: String) -> Redirect { async fn new_kiosk(
db: &State<SqlitePool>,
cookies: &CookieJar<'_>,
loc: String,
ip: IpAddr,
) -> Redirect {
Log::create(
db,
format!("New kiosk cookie set for loc '{loc}' (IP={ip:?})"),
)
.await;
let mut cookie = Cookie::new("kiosk", loc); let mut cookie = Cookie::new("kiosk", loc);
cookie.set_expires(OffsetDateTime::now_utc() + Duration::weeks(12)); cookie.set_expires(OffsetDateTime::now_utc() + Duration::weeks(12));
cookies.add_private(cookie); cookies.add_private(cookie);