From 9f7e2803df80e1f6e446c638dca2f884c965a821 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 10 Apr 2020 03:12:48 -0400 Subject: save sync data to local file --- src/actions.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/actions.rs') diff --git a/src/actions.rs b/src/actions.rs index 14f140e..7d8569c 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -3,12 +3,7 @@ use crate::prelude::*; pub async fn login( email: &str, password: &crate::locked::Password, -) -> Result<( - String, - u32, - crate::cipherstring::CipherString, - crate::locked::Keys, -)> { +) -> Result<(String, String, u32, String, crate::locked::Keys)> { let config = crate::config::Config::load_async().await?; let client = crate::api::Client::new(&config.base_url(), &config.identity_url()); @@ -17,15 +12,15 @@ pub async fn login( let identity = crate::identity::Identity::new(email, password, iterations)?; - let (access_token, _refresh_token, protected_key) = client + let (access_token, refresh_token, protected_key) = client .login(&identity.email, &identity.master_password_hash) .await?; - let protected_key = - crate::cipherstring::CipherString::new(&protected_key)?; - let master_keys = protected_key.decrypt_locked(&identity.keys)?; + let master_keys = crate::cipherstring::CipherString::new(&protected_key)? + .decrypt_locked(&identity.keys)?; Ok(( access_token, + refresh_token, iterations, protected_key, crate::locked::Keys::new(master_keys), @@ -36,11 +31,13 @@ pub async fn unlock( email: &str, password: &crate::locked::Password, iterations: u32, - protected_key: &crate::cipherstring::CipherString, + protected_key: &str, ) -> Result { let identity = crate::identity::Identity::new(email, password, iterations)?; + let protected_key = + crate::cipherstring::CipherString::new(protected_key)?; let master_keys = protected_key.decrypt_locked(&identity.keys)?; Ok(crate::locked::Keys::new(master_keys)) -- cgit v1.2.3-54-g00ecf