make cookie auto-expire at the end of the festival
This commit is contained in:
@@ -14,7 +14,7 @@ use std::{
|
||||
str::FromStr,
|
||||
sync::{Arc, LazyLock},
|
||||
};
|
||||
use time::{Duration, OffsetDateTime};
|
||||
use time::{Date, Month, OffsetDateTime, Time};
|
||||
use tower_http::services::ServeDir;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
|
||||
use uuid::Uuid;
|
||||
@@ -156,7 +156,10 @@ impl Backend {
|
||||
Some(uuid) => (cookies, self.get_client(&uuid).await),
|
||||
None => {
|
||||
let new_id = Uuid::new_v4();
|
||||
let expiration_date = OffsetDateTime::now_utc() + Duration::days(30);
|
||||
let expiration_date = OffsetDateTime::new_utc(
|
||||
Date::from_calendar_date(2025, Month::September, 7).unwrap(),
|
||||
Time::from_hms(20, 0, 0).unwrap(),
|
||||
);
|
||||
let mut cookie = Cookie::new("client_id", new_id.to_string());
|
||||
cookie.set_expires(Expiration::DateTime(expiration_date));
|
||||
cookie.set_http_only(true);
|
||||
|
Reference in New Issue
Block a user