From 941e5d1317b5ed562df2a172de717a5a7408ee15 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Thu, 30 Oct 2025 09:23:02 +0800 Subject: Change auth_member to return MemberId on success The authentication function now returns the authenticated member's ID instead of just () when successful. This provides callers with access to the authenticated member's identity for subsequent operations. --- crates/vcs_actions/src/actions.rs | 12 ++++++------ crates/vcs_actions/src/registry/client_registry.rs | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'crates/vcs_actions/src') diff --git a/crates/vcs_actions/src/actions.rs b/crates/vcs_actions/src/actions.rs index 858695a..795d2b0 100644 --- a/crates/vcs_actions/src/actions.rs +++ b/crates/vcs_actions/src/actions.rs @@ -5,7 +5,7 @@ use tcp_connection::{error::TcpTargetError, instance::ConnectionInstance}; use tokio::sync::Mutex; use vcs_data::{ constants::SERVER_PATH_MEMBER_PUB, - data::{local::LocalWorkspace, user::UserDirectory, vault::Vault}, + data::{local::LocalWorkspace, member::MemberId, user::UserDirectory, vault::Vault}, }; pub mod local_actions; @@ -57,11 +57,11 @@ pub fn try_get_user_directory(ctx: &ActionContext) -> Result, Ok(user_directory) } -/// Authenticate member based on whether the process is running locally or remotely +/// Authenticate member based on context and return MemberId pub async fn auth_member( ctx: &ActionContext, instance: &Arc>, -) -> Result<(), TcpTargetError> { +) -> Result { // Start Challenge (Remote) if ctx.is_proc_on_remote() { let vault = try_get_vault(ctx)?; @@ -72,7 +72,7 @@ pub async fn auth_member( .await; return match result { - Ok(pass) => { + Ok((pass, member_id)) => { if !pass { // Send false to inform the client that authentication failed instance.lock().await.write(false).await?; @@ -82,7 +82,7 @@ pub async fn auth_member( } else { // Send true to inform the client that authentication was successful instance.lock().await.write(true).await?; - Ok(()) + Ok(member_id) } } Err(e) => Err(e), @@ -106,7 +106,7 @@ pub async fn auth_member( // Read result let challenge_result = instance.lock().await.read::().await?; if challenge_result { - return Ok(()); + return Ok(member_name.clone()); } else { return Err(TcpTargetError::Authentication( "Authenticate failed.".to_string(), diff --git a/crates/vcs_actions/src/registry/client_registry.rs b/crates/vcs_actions/src/registry/client_registry.rs index 6f820e6..dcad657 100644 --- a/crates/vcs_actions/src/registry/client_registry.rs +++ b/crates/vcs_actions/src/registry/client_registry.rs @@ -52,7 +52,9 @@ async fn on_proc_begin( let local_workspace = match LocalWorkspace::init_current_dir(local_config) { Some(workspace) => workspace, None => { - return Err(TcpTargetError::NotFound("Failed to initialize local workspace.".to_string())); + return Err(TcpTargetError::NotFound( + "Failed to initialize local workspace.".to_string(), + )); } }; let local_workspace_arc = Arc::new(local_workspace); -- cgit