diff --git a/radicle-cli/src/commands/auth.rs b/radicle-cli/src/commands/auth.rs index c6c83696..7f1d51d0 100644 --- a/radicle-cli/src/commands/auth.rs +++ b/radicle-cli/src/commands/auth.rs @@ -4,6 +4,7 @@ use std::ffi::OsString; use anyhow::anyhow; use radicle::crypto::ssh; +use radicle::profile; use radicle::Profile; use crate::git; @@ -76,9 +77,10 @@ pub fn init(options: Options) -> anyhow::Result<()> { term::blank(); } + let home = profile::home()?; let passphrase = term::read_passphrase(options.stdin, true)?; let spinner = term::spinner("Creating your 🌱 Ed25519 keypair..."); - let profile = Profile::init(passphrase.as_str())?; + let profile = Profile::init(home, passphrase.as_str())?; spinner.finish(); term::success!( diff --git a/radicle-tools/src/rad-auth.rs b/radicle-tools/src/rad-auth.rs index 878642d9..2de1c390 100644 --- a/radicle-tools/src/rad-auth.rs +++ b/radicle-tools/src/rad-auth.rs @@ -1,9 +1,10 @@ +use radicle::profile; use radicle::profile::{Error, Profile}; fn main() -> anyhow::Result<()> { let profile = match Profile::load() { Ok(profile) => profile, - Err(Error::NotFound(_)) => Profile::init("radicle")?, + Err(Error::NotFound(_)) => Profile::init(profile::home()?, "radicle")?, Err(err) => anyhow::bail!(err), }; diff --git a/radicle/src/profile.rs b/radicle/src/profile.rs index ed213a61..6020fdca 100644 --- a/radicle/src/profile.rs +++ b/radicle/src/profile.rs @@ -57,11 +57,9 @@ pub struct Profile { } impl Profile { - pub fn init(passphrase: &str) -> Result { - let home = self::home()?; + pub fn init(home: impl AsRef, passphrase: &str) -> Result { + let home = home.as_ref().to_path_buf(); let storage = Storage::open(&home.join("storage"))?; - // TODO: This should generate a keypair at the given location. - // For now, we use ssh-keygen? let keystore = Keystore::new(&home.join("keys")); let public_key = keystore.init("radicle", passphrase)?;