aboutsummaryrefslogtreecommitdiffstats
path: root/crates/atuin-client/src/login.rs
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@atuin.sh>2025-03-19 12:44:20 +0000
committerGitHub <noreply@github.com>2025-03-19 12:44:20 +0000
commit14ec768b4520d4fc34dbf24e663ea7db940c18b7 (patch)
treea37db707ab8676cad5b3e6ca47af3f2997958906 /crates/atuin-client/src/login.rs
parentfeat: Use readline binding for ctrl-a when it is not the prefix (#2626) (diff)
downloadatuin-14ec768b4520d4fc34dbf24e663ea7db940c18b7.zip
chore: migrate to rust 2024 (#2635)
* chore: upgrade to 2024 edition * ugh unsafe * format * nixxxxxxxxxxx why
Diffstat (limited to 'crates/atuin-client/src/login.rs')
-rw-r--r--crates/atuin-client/src/login.rs35
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
+ }
}
}
};