aboutsummaryrefslogtreecommitdiffstats
path: root/src/actions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions.rs')
-rw-r--r--src/actions.rs33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/actions.rs b/src/actions.rs
index 0d8c88d..02ec854 100644
--- a/src/actions.rs
+++ b/src/actions.rs
@@ -1,37 +1,42 @@
use crate::prelude::*;
+pub async fn register(
+ email: &str,
+ apikey: crate::locked::ApiKey,
+) -> Result<()> {
+ let config = crate::config::Config::load_async().await?;
+ let client =
+ crate::api::Client::new(&config.base_url(), &config.identity_url());
+
+ client.register(email, &config.device_id, &apikey).await?;
+
+ Ok(())
+}
+
pub async fn login(
email: &str,
- password: &crate::locked::Password,
+ password: crate::locked::Password,
two_factor_token: Option<&str>,
two_factor_provider: Option<crate::api::TwoFactorProviderType>,
-) -> Result<(String, String, u32, String, crate::locked::Keys)> {
+) -> Result<(String, String, u32, String)> {
let config = crate::config::Config::load_async().await?;
let client =
crate::api::Client::new(&config.base_url(), &config.identity_url());
let iterations = client.prelogin(email).await?;
let identity =
- crate::identity::Identity::new(email, password, iterations)?;
-
+ crate::identity::Identity::new(email, &password, iterations)?;
let (access_token, refresh_token, protected_key) = client
.login(
- &identity.email,
+ email,
+ &config.device_id,
&identity.master_password_hash,
two_factor_token,
two_factor_provider,
)
.await?;
- let master_keys = crate::cipherstring::CipherString::new(&protected_key)?
- .decrypt_locked_symmetric(&identity.keys)?;
- Ok((
- access_token,
- refresh_token,
- iterations,
- protected_key,
- crate::locked::Keys::new(master_keys),
- ))
+ Ok((access_token, refresh_token, iterations, protected_key))
}
pub async fn unlock(