diff options
Diffstat (limited to 'crates/atuin-client/src/login.rs')
| -rw-r--r-- | crates/atuin-client/src/login.rs | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/crates/atuin-client/src/login.rs b/crates/atuin-client/src/login.rs index 05303464..78168c7e 100644 --- a/crates/atuin-client/src/login.rs +++ b/crates/atuin-client/src/login.rs @@ -1,13 +1,13 @@ use std::path::PathBuf; use atuin_common::api::LoginRequest; -use eyre::{bail, Context, Result}; +use eyre::{Context, Result, bail}; use tokio::fs::File; use tokio::io::AsyncWriteExt; use crate::{ api_client, - encryption::{decode_key, encode_key, load_key, Key}, + encryption::{Key, decode_key, encode_key, load_key}, record::{sqlite_store::SqliteStore, store::Store}, settings::Settings, }; @@ -23,22 +23,25 @@ pub async fn login( let key = match bip39::Mnemonic::from_phrase(&key, bip39::Language::English) { Ok(mnemonic) => encode_key(Key::from_slice(mnemonic.entropy()))?, Err(err) => { - if let Some(err) = err.downcast_ref::<bip39::ErrorKind>() { - match err { - // assume they copied in the base64 key - bip39::ErrorKind::InvalidWord => key, - bip39::ErrorKind::InvalidChecksum => { - bail!("key mnemonic was not valid") - } - bip39::ErrorKind::InvalidKeysize(_) - | bip39::ErrorKind::InvalidWordLength(_) - | bip39::ErrorKind::InvalidEntropyLength(_, _) => { - bail!("key was not the correct length") + match err.downcast_ref::<bip39::ErrorKind>() { + Some(err) => { + match err { + // assume they copied in the base64 key + bip39::ErrorKind::InvalidWord => key, + bip39::ErrorKind::InvalidChecksum => { + bail!("key mnemonic was not valid") + } + bip39::ErrorKind::InvalidKeysize(_) + | bip39::ErrorKind::InvalidWordLength(_) + | bip39::ErrorKind::InvalidEntropyLength(_, _) => { + bail!("key was not the correct length") + } } } - } else { - // unknown error. assume they copied the base64 key - key + _ => { + // unknown error. assume they copied the base64 key + key + } } } }; |
