diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-10-27 22:16:46 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-10-27 22:16:46 -0400 |
commit | 5d0e308c1c57bea30d2ad9008b6dbc7936d58645 (patch) | |
tree | 3c3798d5fb826aeaca62e11d9e56e1e3b610ca2b /src/actions.rs | |
parent | 7b95f7b9d84c44ca273c1a1ce7ab62925d4a5def (diff) | |
download | rbw-5d0e308c1c57bea30d2ad9008b6dbc7936d58645.tar.gz rbw-5d0e308c1c57bea30d2ad9008b6dbc7936d58645.zip |
add a separate "register" command to log in with api keys
Diffstat (limited to 'src/actions.rs')
-rw-r--r-- | src/actions.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/actions.rs b/src/actions.rs index b65226c..02ec854 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -1,8 +1,21 @@ 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, - creds: crate::locked::LoginCredentials, + password: crate::locked::Password, two_factor_token: Option<&str>, two_factor_provider: Option<crate::api::TwoFactorProviderType>, ) -> Result<(String, String, u32, String)> { @@ -11,11 +24,13 @@ pub async fn login( 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)?; let (access_token, refresh_token, protected_key) = client .login( email, &config.device_id, - &creds.to_hashed(email, iterations)?, + &identity.master_password_hash, two_factor_token, two_factor_provider, ) |