diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-10-30 09:23:02 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2025-10-30 09:23:02 +0800 |
| commit | 941e5d1317b5ed562df2a172de717a5a7408ee15 (patch) | |
| tree | c679a5c0d16d38e51f3b66caba212c4ba93bd3a0 /crates/vcs_actions | |
| parent | cc43704e7412ef82f6d41ba211b50e26307a3ddf (diff) | |
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.
Diffstat (limited to 'crates/vcs_actions')
| -rw-r--r-- | crates/vcs_actions/src/actions.rs | 12 | ||||
| -rw-r--r-- | crates/vcs_actions/src/registry/client_registry.rs | 4 |
2 files changed, 9 insertions, 7 deletions
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<Arc<UserDirectory>, 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<Mutex<ConnectionInstance>>, -) -> Result<(), TcpTargetError> { +) -> Result<MemberId, TcpTargetError> { // 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::<bool>().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); |
