aboutsummaryrefslogtreecommitdiffstats
path: root/src/actions.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-04-10 03:12:48 -0400
committerJesse Luehrs <doy@tozt.net>2020-04-10 03:12:48 -0400
commit9f7e2803df80e1f6e446c638dca2f884c965a821 (patch)
tree03872e81096fee84dd88bea31338539117d85222 /src/actions.rs
parentb3a04c4a143c34ba92008cf018eed159f87a0c6e (diff)
downloadrbw-9f7e2803df80e1f6e446c638dca2f884c965a821.tar.gz
rbw-9f7e2803df80e1f6e446c638dca2f884c965a821.zip
save sync data to local file
Diffstat (limited to 'src/actions.rs')
-rw-r--r--src/actions.rs19
1 files changed, 8 insertions, 11 deletions
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<crate::locked::Keys> {
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))