44RUBHREQUNI4B36WSV7CUK5CVVIKG2AQOQJQZ7HU3BHY6W6AUEQC
// match create_identity(Some(old_identity.clone()), no_prompt).await {
if let Err(e) = old_identity.clone().create(no_prompt, true).await {
match e {
IdentityCreateError::ProveFailed(name) => writeln!(stderr, "Failed to prove identity. You will still be able to create & sign patches, but until you run `pijul identity prove --name {name}` they will not be linked to your personal details. If you are on an enterprise network, perhaps try running with `--no-cert-check`")?,
IdentityCreateError::Other(err) => return Err(err),
}
};
old_identity.clone().create(no_prompt, true).await?;
#[derive(Error, Debug)]
pub enum IdentityCreateError {
#[error("Could not prove identity {0}. Please check your credentials & network connection. If you are on an enterprise network, perhaps try running with `--no-cert-check`")]
ProveFailed(String),
#[error(transparent)]
Other(#[from] anyhow::Error),
}
new_identity.prompt_remote(link_remote).await?;
new_identity.prompt_remote().await?;
// There are 3 cases that require re-proving:
// 1: new identity (replace_current == None)
// 2: new secret key
// 3. new username/origin
if to_replace.is_none()
|| self.secret_key() != new_identity.secret_key()
|| (&self.config.author.origin, &self.config.author.username)
!= (
&new_identity.config.author.origin,
&new_identity.config.author.username,
)
{
// Prove the identity to the server
if link_remote
&& new_identity
.prove(*NO_CERT_CHECK.get_or_init(|| false))
.await
.is_err()
{
error!("Could not prove identity `{}`. Please check your credentials & network connection. If you are on an enterprise network, perhaps try running with `--no-cert-check`. Your data is safe but will not be connected to {} without runnning `pijul identity prove {}`", new_identity.name, new_identity.config.author.origin, new_identity.name);
}
}
pub async fn create(
&self,
no_prompt: bool,
link_remote: bool,
) -> Result<(), IdentityCreateError> {
pub async fn create(&self, no_prompt: bool, link_remote: bool) -> Result<(), anyhow::Error> {