@@ -5,6 +5,7 @@ use rocket::request::{FromRequest, Outcome, Request};
55use rocket:: State ;
66use sqlx:: PgPool ;
77
8+ use crate :: models:: User ;
89use crate :: { Clusters , Context } ;
910
1011pub fn default_database_url ( ) ->String {
@@ -46,17 +47,31 @@ impl<'r> FromRequest<'r> for Cluster {
4647None => -1 ,
4748} ;
4849
49- let shared_state =match request. guard :: < & State < Clusters > > ( ) . await {
50+ let user_id: i64 =match cookies. get_private ( "user_id" ) {
51+ Some ( user_id) =>match user_id. value ( ) . parse :: < i64 > ( ) {
52+ Ok ( user_id) => user_id,
53+ Err ( _) => -1 ,
54+ } ,
55+
56+ None => -1 ,
57+ } ;
58+
59+ let clusters_shared_state =match request. guard :: < & State < Clusters > > ( ) . await {
5060Outcome :: Success ( pool) => pool,
5161 _ =>return Outcome :: Forward ( ( ) ) ,
5262} ;
5363
54- let pool =shared_state . get ( cluster_id) ;
64+ let pool =clusters_shared_state . get ( cluster_id) ;
5565
5666let context =Context {
57- user : shared_state. get_context ( cluster_id) . user ,
58- cluster : shared_state. get_context ( cluster_id) . cluster ,
59- visible_clusters : shared_state. get_context ( cluster_id) . visible_clusters ,
67+ user : User {
68+ id : user_id,
69+ email : "" . to_string ( ) ,
70+ } ,
71+ cluster : clusters_shared_state. get_context ( cluster_id) . cluster ,
72+ visible_clusters : clusters_shared_state
73+ . get_context ( cluster_id)
74+ . visible_clusters ,
6075} ;
6176
6277Outcome :: Success ( Cluster { pool, context} )