From a971d8c2dc519b1db805c72cf3395c188a98dff4 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Wed, 13 Dec 2023 06:50:44 +0000 Subject: switch to uuids --- src/routes/home.rs | 3 ++- src/routes/login.rs | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/routes') diff --git a/src/routes/home.rs b/src/routes/home.rs index a43eabc..f2642a5 100644 --- a/src/routes/home.rs +++ b/src/routes/home.rs @@ -1,5 +1,6 @@ use actix_session::Session; use actix_web::{get, web, HttpResponse}; +use uuid::Uuid; use crate::templates; use crate::{Pinussy, Result}; @@ -7,7 +8,7 @@ use crate::{Pinussy, Result}; #[get("/")] async fn get(session: Session, state: web::Data) -> Result { let username: Option; - if let Some(user_id) = session.get::("user_id")? { + if let Some(user_id) = session.get::("user_id")? { username = Some(state.db.users().read(user_id).await?.username) } else { username = None diff --git a/src/routes/login.rs b/src/routes/login.rs index c6cf077..bd7eaf1 100644 --- a/src/routes/login.rs +++ b/src/routes/login.rs @@ -30,8 +30,7 @@ async fn post( match state.db.users().read_username(&form.username).await { Ok(user) => { if user.verify_password(&form.password)? { - let user_id = state.db.users().get_id(&form.username).await?; - session.insert("user_id", user_id)?; + session.insert("user_id", user.id)?; return Ok(HttpResponse::SeeOther() .insert_header((LOCATION, "/")) .finish()); -- cgit