diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-12-13 16:09:01 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-12-13 16:09:01 +0100 |
commit | 064a1077c8c66fe8d3ee71f831c930e1ddfbc34a (patch) | |
tree | 41d8556aa5d871921a64b081ba157ade212558d8 /src/main.rs | |
parent | 47e25cd7f710fcd82356377cf48eccf9f65d31cc (diff) | |
download | aerogramme-064a1077c8c66fe8d3ee71f831c930e1ddfbc34a.tar.gz aerogramme-064a1077c8c66fe8d3ee71f831c930e1ddfbc34a.zip |
it compiles again!
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/main.rs b/src/main.rs index c252623..3b5f474 100644 --- a/src/main.rs +++ b/src/main.rs @@ -156,17 +156,6 @@ fn account_management(root: &Command, cmd: &AccountManagement, users: PathBuf) - tracing::debug!(user=login, "will-create"); let stp: SetupEntry = read_config(setup.clone())?; tracing::debug!(user=login, "loaded setup entry"); - let crypto_root = match root { - Command::Provider(_) => CryptographyRoot::PasswordProtected, - Command::Companion(_) => { - // @TODO use keyring by default instead of inplace in the future - // @TODO generate keys - CryptographyRoot::InPlace { - master_key: "".to_string(), - secret_key: "".to_string(), - } - } - }; let password = match stp.clear_password { Some(pwd) => pwd, @@ -179,12 +168,19 @@ fn account_management(root: &Command, cmd: &AccountManagement, users: PathBuf) - password } }; + + let crypto_keys = CryptoKeys::init(); + let crypto_root = match root { + Command::Provider(_) => CryptoRoot::create_pass(&password, &crypto_keys)?, + Command::Companion(_) => CryptoRoot::create_cleartext(&crypto_keys), + }; + let hash = hash_password(password.as_str()).context("unable to hash password")?; ulist.insert(login.clone(), UserEntry { email_addresses: stp.email_addresses, password: hash, - crypto_root, + crypto_root: crypto_root.0, storage: stp.storage, }); @@ -192,7 +188,7 @@ fn account_management(root: &Command, cmd: &AccountManagement, users: PathBuf) - }, AccountManagement::Delete { login } => { tracing::debug!(user=login, "will-delete"); - ulist.remove(&login); + ulist.remove(login); write_config(users.clone(), &ulist)?; }, AccountManagement::ChangePassword { login } => { |