diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-21 16:53:17 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-21 16:53:17 +0000 |
| commit | f79014235e85554e3661b3f2a02b8fa88bc192ff (patch) | |
| tree | fceec3ff2df212148a3420af7cef81a3f818463e /src/bin/ngit/sub_commands/init.rs | |
| parent | 91b0eac4daf92b7b740267ef203a1a8ba591974b (diff) | |
feat(login): overhaul login experience
* simplify login menu, making it more accessable to newcomers and
easier to select remote signer options
* enable `ngit login` to work from anywhere (not just a git repo)
* assume fresh login details saved to global git config but fallback
to local repository
* maintain local repository login via `ngit login --local`
* maintain login via CLI arguments eg `ngit send --nsec nsec123`
* nudge users to remember nsec when pasting in ncryptsec for a
better UX, whilst maintaining the option to be prompted for
password everytime
* create placeholder menu items for help menu and create account
Diffstat (limited to 'src/bin/ngit/sub_commands/init.rs')
| -rw-r--r-- | src/bin/ngit/sub_commands/init.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index aa43106..146a29c 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs | |||
| @@ -6,7 +6,7 @@ use nostr::{nips::nip01::Coordinate, FromBech32, PublicKey, ToBech32}; | |||
| 6 | use nostr_sdk::Kind; | 6 | use nostr_sdk::Kind; |
| 7 | 7 | ||
| 8 | use crate::{ | 8 | use crate::{ |
| 9 | cli::Cli, | 9 | cli::{extract_signer_cli_arguments, Cli}, |
| 10 | cli_interactor::{Interactor, InteractorPrompt, PromptInputParms}, | 10 | cli_interactor::{Interactor, InteractorPrompt, PromptInputParms}, |
| 11 | client::{fetching_with_report, get_repo_ref_from_cache, send_events, Client, Connect}, | 11 | client::{fetching_with_report, get_repo_ref_from_cache, send_events, Client, Connect}, |
| 12 | git::{nostr_url::convert_clone_url_to_https, Repo, RepoActions}, | 12 | git::{nostr_url::convert_clone_url_to_https, Repo, RepoActions}, |
| @@ -69,7 +69,8 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 69 | 69 | ||
| 70 | let repo_ref = if let Some(repo_coordinates) = repo_coordinates.clone() { | 70 | let repo_ref = if let Some(repo_coordinates) = repo_coordinates.clone() { |
| 71 | fetching_with_report(git_repo_path, &client, &repo_coordinates).await?; | 71 | fetching_with_report(git_repo_path, &client, &repo_coordinates).await?; |
| 72 | if let Ok(repo_ref) = get_repo_ref_from_cache(git_repo_path, &repo_coordinates).await { | 72 | if let Ok(repo_ref) = get_repo_ref_from_cache(Some(git_repo_path), &repo_coordinates).await |
| 73 | { | ||
| 73 | Some(repo_ref) | 74 | Some(repo_ref) |
| 74 | } else { | 75 | } else { |
| 75 | None | 76 | None |
| @@ -78,15 +79,11 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 78 | None | 79 | None |
| 79 | }; | 80 | }; |
| 80 | 81 | ||
| 81 | let (signer, user_ref) = login::launch( | 82 | let (signer, user_ref, _) = login::login_or_signup( |
| 82 | &git_repo, | 83 | &Some(&git_repo), |
| 83 | &cli_args.bunker_uri, | 84 | &extract_signer_cli_arguments(cli_args).unwrap_or(None), |
| 84 | &cli_args.bunker_app_key, | ||
| 85 | &cli_args.nsec, | ||
| 86 | &cli_args.password, | 85 | &cli_args.password, |
| 87 | Some(&client), | 86 | Some(&client), |
| 88 | false, | ||
| 89 | false, | ||
| 90 | ) | 87 | ) |
| 91 | .await?; | 88 | .await?; |
| 92 | 89 | ||
| @@ -381,7 +378,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 381 | 378 | ||
| 382 | send_events( | 379 | send_events( |
| 383 | &client, | 380 | &client, |
| 384 | git_repo_path, | 381 | Some(git_repo_path), |
| 385 | vec![repo_event], | 382 | vec![repo_event], |
| 386 | user_ref.relays.write(), | 383 | user_ref.relays.write(), |
| 387 | relays.clone(), | 384 | relays.clone(), |