From a0fb08392263988b9982ba33e60eca313627195a Mon Sep 17 00:00:00 2001 From: xeovalyte Date: Wed, 9 Oct 2024 13:11:45 +0200 Subject: [PATCH] Fixed logout not working --- docker-compose.yml | 2 ++ src/util/model/session.rs | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2bc8eeb..0235ce8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,4 +14,6 @@ services: - "root" - --pass - "root" + - --log + - debug - rocksdb:/data/database.db diff --git a/src/util/model/session.rs b/src/util/model/session.rs index 613a9b0..00b3c45 100644 --- a/src/util/model/session.rs +++ b/src/util/model/session.rs @@ -3,6 +3,8 @@ use crate::util::surrealdb::{thing_to_string, DB}; use dioxus::prelude::*; use serde::{Deserialize, Serialize}; +#[cfg(feature = "server")] +use surrealdb::sql::Thing; use super::user::User; @@ -114,10 +116,10 @@ impl Session { Ok(()) } - pub async fn delete_session(user_id: String) -> Result<(), crate::Error> { + pub async fn delete_session(session_token: String) -> Result<(), crate::Error> { let res = DB - .query("DELETE ONLY session WHERE user = type::thing('user', $user_id)") - .bind(("user_id", user_id)) + .query("DELETE session WHERE token = $session_token") + .bind(("session_token", session_token)) .await?; res.check()?;