diff options
author | Cara Salter <cara@devcara.com> | 2022-07-20 08:32:05 -0400 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2022-07-20 08:32:05 -0400 |
commit | b98646d8501689072f5624483d258adcbf6fc5c5 (patch) | |
tree | 98dd43a64193b1b383f2f785f658c6b4d7371854 /src | |
parent | f42bf29ba97fc808433ae4217fd6b00469a12fae (diff) | |
download | nccd-b98646d8501689072f5624483d258adcbf6fc5c5.tar.gz nccd-b98646d8501689072f5624483d258adcbf6fc5c5.zip |
auth: Set path to root for cookies
Diffstat (limited to 'src')
-rw-r--r-- | src/handlers/auth.rs | 4 | ||||
-rw-r--r-- | src/main.rs | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/handlers/auth.rs b/src/handlers/auth.rs index 7e2642c..c00fb8d 100644 --- a/src/handlers/auth.rs +++ b/src/handlers/auth.rs @@ -43,7 +43,9 @@ pub async fn login_post(Form(login): Form<LoginForm>, state: Extension<Arc<State .execute(&mut conn) .await?; - let updated_jar = jar.add(Cookie::new("user-id", user.id.clone())); + let updated_jar = jar.add(Cookie::build("user-id", user.id.clone()) + .path("/") + .finish()); Ok((updated_jar, Redirect::to("/"))) } else { diff --git a/src/main.rs b/src/main.rs index acc9f9f..ab03fb3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,14 +9,14 @@ use axum::body; use axum::extract::Path; use axum::{error_handling::HandleErrorLayer, routing::get, BoxError, Extension, Router}; use axum::response::{Html, IntoResponse, Response}; -use axum_extra::extract::PrivateCookieJar; +use axum_extra::extract::{PrivateCookieJar, SignedCookieJar}; use axum_extra::extract::cookie::Key; use errors::{StringResult, HtmlResult}; use hyper::StatusCode; use sqlx::{PgPool, postgres::PgPoolOptions}; use tower::ServiceBuilder; use tower_http::trace::TraceLayer; -use tracing::{error, info, debug}; +use tracing::{error, info, debug, trace}; use crate::errors::ServiceError; use tracing_subscriber::prelude::*; use crate::models::DbUser; @@ -117,7 +117,7 @@ async fn index(state: Extension<Arc<State>>, jar: PrivateCookieJar) -> HtmlResul async fn statics(Path(name): Path<String>) -> Result<Response, ServiceError> { for s in templates::statics::STATICS { - debug!("Name: {}\nContents:\n{:?}\n\n", s.name, s.content); + trace!("Name: {}\nContents:\n{:?}\n\n", s.name, s.content); } match templates::statics::StaticFile::get(&name) { |