From e522f358e5245fd8e0faa6074e7f1387bc95e36d Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Sun, 15 Jan 2023 22:50:48 +0100 Subject: [PATCH] Change mutation to quickly test if a user is connected or not --- src/graphql/mutation.rs | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/graphql/mutation.rs b/src/graphql/mutation.rs index 1c468b4..2fc5d25 100644 --- a/src/graphql/mutation.rs +++ b/src/graphql/mutation.rs @@ -5,28 +5,12 @@ pub struct Mutation; #[juniper::graphql_object(Context = Context)] impl Mutation { fn api_version( - session_id: Option, - user_id: Option, context: &Context, ) -> String { - "0.1".into() - // if session_id.is_some() && user_id.is_some() { - // match context - // .appwrite - // .check_session(session_id.unwrap(), user_id.unwrap()) - // { - // Ok(true) => "0.1 (authentified)".into(), - // Ok(false) => "0.1 (not authentified)".into(), - // Err(e) => { - // info!( - // "Error while checking if the user is connected: {:?}", - // e - // ); - // "0.1 (auth failed)" - // } - // } - // } else { - // "0.1 (not authentified)" - // } + if context.user_auth { + "0.1 (authentified)" + } else { + "0.1 (not authentified)" + }.into() } }