upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-11-11 17:20:37 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2024-11-11 22:09:53 +0000
commit574acb16414bca4b30e77abca64ee180695109c3 (patch)
treef25cf02aa9cd203d9531be2f9ea5fa4288915680
parent694325fa25e281b1a4c9d7f275f1a8e0f1ad7abf (diff)
fix(login): only get signer npub when unknown
on get the user public key from the remote signer when it is unknown so that read operations aren't blocked by being unable to reach remote signer
-rw-r--r--src/lib/login/mod.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/login/mod.rs b/src/lib/login/mod.rs
index 148b9d7..de82c01 100644
--- a/src/lib/login/mod.rs
+++ b/src/lib/login/mod.rs
@@ -65,8 +65,7 @@ pub async fn launch(
65 eprintln!( 65 eprintln!(
66 "login as {}", 66 "login as {}",
67 if let Ok(public_key) = PublicKey::from_bech32( 67 if let Ok(public_key) = PublicKey::from_bech32(
68 get_config_item(git_repo, "nostr.npub") 68 get_config_item(git_repo, "nostr.npub").unwrap_or("unknown".to_string()),
69 .unwrap_or("unknown ncryptsec".to_string()),
70 ) { 69 ) {
71 if let Ok(user_ref) = 70 if let Ok(user_ref) =
72 get_user_details(&public_key, client, git_repo.get_path()?, silent) 71 get_user_details(&public_key, client, git_repo.get_path()?, silent)
@@ -99,16 +98,17 @@ pub async fn launch(
99 } 98 }
100 } { 99 } {
101 // get user ref 100 // get user ref
102 let user_ref = get_user_details( 101 let public_key = if let Ok(public_key) = PublicKey::from_bech32(
103 &signer 102 get_config_item(git_repo, "nostr.npub").unwrap_or("unknown".to_string()),
103 ) {
104 public_key
105 } else {
106 signer
104 .get_public_key() 107 .get_public_key()
105 .await 108 .await
106 .context("cannot get public key from signer")?, 109 .context("cannot get public key from signer")?
107 client, 110 };
108 git_repo.get_path()?, 111 let user_ref = get_user_details(&public_key, client, git_repo.get_path()?, silent).await?;
109 silent,
110 )
111 .await?;
112 if !silent { 112 if !silent {
113 print_logged_in_as(&user_ref, client.is_none())?; 113 print_logged_in_as(&user_ref, client.is_none())?;
114 } 114 }