upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/lib/login/mod.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-11-11 17:20:37 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2024-11-11 17:20:37 +0000
commit86c6d91786b65e513b346350af4b05b205fa157f (patch)
tree9f3ca53583e12b81967408045aaa4754c26af3b7 /src/lib/login/mod.rs
parent30f1a3efa9265b1403a7aa68fffbd65291face3d (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
Diffstat (limited to 'src/lib/login/mod.rs')
-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 }