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/login.rs | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'src/bin/ngit/sub_commands/login.rs') diff --git a/src/bin/ngit/sub_commands/login.rs b/src/bin/ngit/sub_commands/login.rs index df7efa5..ae5efb1 100644 --- a/src/bin/ngit/sub_commands/login.rs +++ b/src/bin/ngit/sub_commands/login.rs @@ -5,45 +5,31 @@ use crate::{ cli::Cli, client::{Client, Connect}, git::Repo, - login, + login::fresh::fresh_login_or_signup, }; #[derive(clap::Args)] pub struct SubCommandArgs { + /// login to the local git repository only + #[arg(long, action)] + local: bool, + /// don't fetch user metadata and relay list from relays #[arg(long, action)] offline: bool, } -pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> { +pub async fn launch(_args: &Cli, command_args: &SubCommandArgs) -> Result<()> { let git_repo = Repo::discover().context("cannot find a git repository")?; + // TODO show existing login on record, prompt to logout + // TODO use cli arguments to login if command_args.offline { - login::launch( - &git_repo, - &args.bunker_uri, - &args.bunker_app_key, - &args.nsec, - &args.password, - None, - true, - false, - ) - .await?; + fresh_login_or_signup(&Some(&git_repo), None, command_args.local).await?; Ok(()) } else { let client = Client::default(); + fresh_login_or_signup(&Some(&git_repo), Some(&client), command_args.local).await?; - login::launch( - &git_repo, - &args.bunker_uri, - &args.bunker_app_key, - &args.nsec, - &args.password, - Some(&client), - true, - false, - ) - .await?; client.disconnect().await?; Ok(()) } -- cgit v1.2.3