From c47b3bb44724beabeeb9ff68903cd5b14fbde375 Mon Sep 17 00:00:00 2001 From: philipp Date: Thu, 5 Oct 2023 08:46:34 +0200 Subject: [PATCH] log if new kiosk cookie is set --- src/tera/log.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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);