From 3df3a96d4692004611ff42ccddeeef6138e29fa3 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Fri, 15 Oct 2021 17:34:05 +0900 Subject: [PATCH] app: Fix login cookie expiration format --- app/src/infra/cookies.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/infra/cookies.rs b/app/src/infra/cookies.rs index e3b394e..b3840bf 100644 --- a/app/src/infra/cookies.rs +++ b/app/src/infra/cookies.rs @@ -23,11 +23,14 @@ pub fn set_cookie(cookie_name: &str, value: &str, expiration: &DateTime) -> d.dyn_into::() .map_err(|_| anyhow!("Document is not an HTMLDocument")) })?; - doc.set_cookie(&format!( - "{}={};expires={};sameSite=Strict", - cookie_name, value, expiration - )) - .map_err(|_| anyhow!("Could not set cookie")) + let cookie_string = format!( + "{}={}; expires={}; sameSite=Strict; path=/", + cookie_name, + value, + expiration.to_rfc2822() + ); + doc.set_cookie(&cookie_string) + .map_err(|_| anyhow!("Could not set cookie")) } pub fn get_cookie(cookie_name: &str) -> Result> {