diff options
Diffstat (limited to 'src/login.rs')
| -rw-r--r-- | src/login.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/login.rs b/src/login.rs index ad9902d..e1669c1 100644 --- a/src/login.rs +++ b/src/login.rs | |||
| @@ -3,7 +3,9 @@ use std::str::FromStr; | |||
| 3 | use anyhow::{bail, Context, Result}; | 3 | use anyhow::{bail, Context, Result}; |
| 4 | use nostr::PublicKey; | 4 | use nostr::PublicKey; |
| 5 | use nostr_database::Order; | 5 | use nostr_database::Order; |
| 6 | use nostr_sdk::{Alphabet, FromBech32, JsonUtil, Kind, NostrDatabase, SingleLetterTag, ToBech32}; | 6 | use nostr_sdk::{ |
| 7 | Alphabet, FromBech32, JsonUtil, Kind, NostrDatabase, NostrSigner, SingleLetterTag, ToBech32, | ||
| 8 | }; | ||
| 7 | use nostr_sqlite::SQLiteDatabase; | 9 | use nostr_sqlite::SQLiteDatabase; |
| 8 | 10 | ||
| 9 | #[cfg(not(test))] | 11 | #[cfg(not(test))] |
| @@ -28,7 +30,7 @@ pub async fn launch( | |||
| 28 | #[cfg(test)] client: Option<&MockConnect>, | 30 | #[cfg(test)] client: Option<&MockConnect>, |
| 29 | #[cfg(not(test))] client: Option<&Client>, | 31 | #[cfg(not(test))] client: Option<&Client>, |
| 30 | change_user: bool, | 32 | change_user: bool, |
| 31 | ) -> Result<(nostr::Keys, UserRef)> { | 33 | ) -> Result<(NostrSigner, UserRef)> { |
| 32 | if let Ok(keys) = match get_keys_without_prompts(git_repo, nsec, password, change_user) { | 34 | if let Ok(keys) = match get_keys_without_prompts(git_repo, nsec, password, change_user) { |
| 33 | Ok(keys) => Ok(keys), | 35 | Ok(keys) => Ok(keys), |
| 34 | Err(error) => { | 36 | Err(error) => { |
| @@ -73,7 +75,7 @@ pub async fn launch( | |||
| 73 | // get user ref | 75 | // get user ref |
| 74 | let user_ref = get_user_details(&keys.public_key(), client, git_repo).await?; | 76 | let user_ref = get_user_details(&keys.public_key(), client, git_repo).await?; |
| 75 | print_logged_in_as(&user_ref, client.is_none())?; | 77 | print_logged_in_as(&user_ref, client.is_none())?; |
| 76 | Ok((keys, user_ref)) | 78 | Ok((NostrSigner::Keys(keys), user_ref)) |
| 77 | } else { | 79 | } else { |
| 78 | fresh_login(git_repo, client, change_user).await | 80 | fresh_login(git_repo, client, change_user).await |
| 79 | } | 81 | } |
| @@ -172,7 +174,7 @@ async fn fresh_login( | |||
| 172 | #[cfg(test)] client: Option<&MockConnect>, | 174 | #[cfg(test)] client: Option<&MockConnect>, |
| 173 | #[cfg(not(test))] client: Option<&Client>, | 175 | #[cfg(not(test))] client: Option<&Client>, |
| 174 | always_save: bool, | 176 | always_save: bool, |
| 175 | ) -> Result<(nostr::Keys, UserRef)> { | 177 | ) -> Result<(NostrSigner, UserRef)> { |
| 176 | // prompt for nsec | 178 | // prompt for nsec |
| 177 | let mut prompt = "login with nsec"; | 179 | let mut prompt = "login with nsec"; |
| 178 | let keys = loop { | 180 | let keys = loop { |
| @@ -196,7 +198,7 @@ async fn fresh_login( | |||
| 196 | } | 198 | } |
| 197 | let user_ref = get_user_details(&keys.public_key(), client, git_repo).await?; | 199 | let user_ref = get_user_details(&keys.public_key(), client, git_repo).await?; |
| 198 | print_logged_in_as(&user_ref, client.is_none())?; | 200 | print_logged_in_as(&user_ref, client.is_none())?; |
| 199 | Ok((keys, user_ref)) | 201 | Ok((NostrSigner::Keys(keys), user_ref)) |
| 200 | } | 202 | } |
| 201 | 203 | ||
| 202 | fn save_keys(git_repo: &Repo, keys: &nostr::Keys, always_save: bool) -> Result<()> { | 204 | fn save_keys(git_repo: &Repo, keys: &nostr::Keys, always_save: bool) -> Result<()> { |