app: Fix login cookie expiration format

This commit is contained in:
Valentin Tolmer 2021-10-15 17:34:05 +09:00 committed by nitnelave
parent f4edb99379
commit 3df3a96d46

View File

@ -23,10 +23,13 @@ pub fn set_cookie(cookie_name: &str, value: &str, expiration: &DateTime<Utc>) ->
d.dyn_into::<web_sys::HtmlDocument>() d.dyn_into::<web_sys::HtmlDocument>()
.map_err(|_| anyhow!("Document is not an HTMLDocument")) .map_err(|_| anyhow!("Document is not an HTMLDocument"))
})?; })?;
doc.set_cookie(&format!( let cookie_string = format!(
"{}={};expires={};sameSite=Strict", "{}={}; expires={}; sameSite=Strict; path=/",
cookie_name, value, expiration cookie_name,
)) value,
expiration.to_rfc2822()
);
doc.set_cookie(&cookie_string)
.map_err(|_| anyhow!("Could not set cookie")) .map_err(|_| anyhow!("Could not set cookie"))
} }