Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Commit

Permalink
⬆️ Upgrade cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenein committed Oct 21, 2023
1 parent ddea9dc commit cbfa605
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bytes = "1.5.0"
chrono = { version = "0.4.31", default-features = false, features = ["std", "clock", "serde"] }
chrono-humanize = "0.2.3"
clap = { version = "4.4.5", features = ["derive", "env", "cargo"] }
cookie = "0.17.0"
cookie = "0.18.0"
crc32fast = "1.3.2"
derive_more = { version = "0.99.17", default-features = false, features = ["from"] }
dotenvy = "0.15.7"
Expand Down
4 changes: 2 additions & 2 deletions src/web/views/authenticate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ pub async fn get(

info!(user.nickname, %user.session_id, "👋 Welcome");
state.session_manager.insert(&user).await?;
let cookie = cookie::Cookie::build(User::SESSION_COOKIE_NAME, user.session_id.to_string())
let cookie = cookie::Cookie::build((User::SESSION_COOKIE_NAME, user.session_id.to_string()))
.http_only(true)
.expires(user.expires_at()?)
.same_site(SameSite::Strict)
.secure(true)
.finish();
.build();

// Workaround for Chrome & Firefox not sending the cookie after the redirect.
let markup = html! {
Expand Down
4 changes: 2 additions & 2 deletions src/web/views/sign_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ pub async fn get(
}
}

let cookie = cookie::Cookie::build(User::SESSION_COOKIE_NAME, "")
let cookie = cookie::Cookie::build(User::SESSION_COOKIE_NAME)
.http_only(true)
.max_age(Duration::new(0, 0))
.finish();
.build();

Ok(([(SET_COOKIE, cookie.to_string())], Redirect::temporary("/")))
}

0 comments on commit cbfa605

Please sign in to comment.