diff --git a/src/tera/log.rs b/src/tera/log.rs index 738a26f..bb11581 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -1,3 +1,5 @@ +use std::net::IpAddr; + use rocket::{ form::Form, get, @@ -15,6 +17,7 @@ use tera::Context; use crate::model::{ boat::Boat, + log::Log, logbook::{ LogToAdd, LogToFinalize, Logbook, LogbookCreateError, LogbookDeleteError, LogbookUpdateError, @@ -91,7 +94,17 @@ async fn show_kiosk(db: &State, _kiosk: KioskCookie) -> Template { } #[get("/kiosk/ekrv2019/")] -fn new_kiosk(cookies: &CookieJar<'_>, loc: String) -> Redirect { +async fn new_kiosk( + db: &State, + 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); cookie.set_expires(OffsetDateTime::now_utc() + Duration::weeks(12)); cookies.add_private(cookie);