From f79014235e85554e3661b3f2a02b8fa88bc192ff Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 21 Nov 2024 16:53:17 +0000 Subject: 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 --- src/bin/ngit/sub_commands/init.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/bin/ngit/sub_commands/init.rs') 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}; use nostr_sdk::Kind; use crate::{ - cli::Cli, + cli::{extract_signer_cli_arguments, Cli}, cli_interactor::{Interactor, InteractorPrompt, PromptInputParms}, client::{fetching_with_report, get_repo_ref_from_cache, send_events, Client, Connect}, git::{nostr_url::convert_clone_url_to_https, Repo, RepoActions}, @@ -69,7 +69,8 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { let repo_ref = if let Some(repo_coordinates) = repo_coordinates.clone() { fetching_with_report(git_repo_path, &client, &repo_coordinates).await?; - if let Ok(repo_ref) = get_repo_ref_from_cache(git_repo_path, &repo_coordinates).await { + if let Ok(repo_ref) = get_repo_ref_from_cache(Some(git_repo_path), &repo_coordinates).await + { Some(repo_ref) } else { None @@ -78,15 +79,11 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { None }; - let (signer, user_ref) = login::launch( - &git_repo, - &cli_args.bunker_uri, - &cli_args.bunker_app_key, - &cli_args.nsec, + let (signer, user_ref, _) = login::login_or_signup( + &Some(&git_repo), + &extract_signer_cli_arguments(cli_args).unwrap_or(None), &cli_args.password, Some(&client), - false, - false, ) .await?; @@ -381,7 +378,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { send_events( &client, - git_repo_path, + Some(git_repo_path), vec![repo_event], user_ref.relays.write(), relays.clone(), -- cgit v1.2.3