diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-04-08 03:52:52 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-04-08 03:52:52 -0400 |
commit | bc04f794ca08395577d507c0a746d3d7b01e29dc (patch) | |
tree | 868b0c8afdc1bb7a7d42c6383e77d21b064e3704 /src/actions.rs | |
parent | 56d47b757da04bdb4414e350e6438a93242f53c8 (diff) | |
download | rbw-bc04f794ca08395577d507c0a746d3d7b01e29dc.tar.gz rbw-bc04f794ca08395577d507c0a746d3d7b01e29dc.zip |
automatically unlock on login
Diffstat (limited to 'src/actions.rs')
-rw-r--r-- | src/actions.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/actions.rs b/src/actions.rs index 0402a10..10ce357 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -3,7 +3,7 @@ use crate::prelude::*; pub async fn login( email: &str, password: &crate::locked::Password, -) -> Result<(String, u32, String)> { +) -> Result<(String, u32, String, crate::locked::Keys)> { let client = crate::api::Client::new_self_hosted("https://bitwarden.tozt.net"); @@ -14,8 +14,16 @@ pub async fn login( let (access_token, _refresh_token, protected_key) = client .login(&identity.email, &identity.master_password_hash) .await?; - - Ok((access_token, iterations, protected_key)) + let protected_key_cs = + crate::cipherstring::CipherString::new(&protected_key)?; + let master_keys = protected_key_cs.decrypt_locked(&identity.keys)?; + + Ok(( + access_token, + iterations, + protected_key, + crate::locked::Keys::new(master_keys), + )) } pub async fn unlock( |