diff --git a/pgml-dashboard/src/guards.rs b/pgml-dashboard/src/guards.rs index c5d1c2479..b3380daab 100644 --- a/pgml-dashboard/src/guards.rs +++ b/pgml-dashboard/src/guards.rs @@ -5,6 +5,7 @@ use rocket::request::{FromRequest, Outcome, Request}; use rocket::State; use sqlx::PgPool; +use crate::models::User; use crate::{Clusters, Context}; pub fn default_database_url() -> String { @@ -46,17 +47,31 @@ impl<'r> FromRequest<'r> for Cluster { None => -1, }; - let shared_state = match request.guard::<&State>().await { + let user_id: i64 = match cookies.get_private("user_id") { + Some(user_id) => match user_id.value().parse::() { + Ok(user_id) => user_id, + Err(_) => -1, + }, + + None => -1, + }; + + let clusters_shared_state = match request.guard::<&State>().await { Outcome::Success(pool) => pool, _ => return Outcome::Forward(()), }; - let pool = shared_state.get(cluster_id); + let pool = clusters_shared_state.get(cluster_id); let context = Context { - user: shared_state.get_context(cluster_id).user, - cluster: shared_state.get_context(cluster_id).cluster, - visible_clusters: shared_state.get_context(cluster_id).visible_clusters, + user: User { + id: user_id, + email: "".to_string(), + }, + cluster: clusters_shared_state.get_context(cluster_id).cluster, + visible_clusters: clusters_shared_state + .get_context(cluster_id) + .visible_clusters, }; Outcome::Success(Cluster { pool, context }) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy