diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-10-30 09:26:33 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-30 09:26:33 +0800 |
| commit | 67ddf17efe909128732473b28a100fe2f58fdf46 (patch) | |
| tree | 97382930372225a0cd2735b957da4770170d477c /crates/vcs_actions/src/actions.rs | |
| parent | 4f35da85641549c3e08c4e1b73fccfc7ec9779a2 (diff) | |
| parent | d879d8864864d51f48201ea3fcf43baad2f969f6 (diff) | |
Merge pull request #31 from JustEnoughVCS/jvcs_dev_actions
Jvcs dev actions
Diffstat (limited to 'crates/vcs_actions/src/actions.rs')
| -rw-r--r-- | crates/vcs_actions/src/actions.rs | 12 |
1 files changed, 6 insertions, 6 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(), |
