diff options
| author | Ellie Huxtable <ellie@elliehuxtable.com> | 2024-05-30 12:49:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-30 12:49:22 +0100 |
| commit | 467f89c104df40904ef4c6b408507e90fe661724 (patch) | |
| tree | e93697bdfa14ca6b083b0ea02c85d1d0688e0eba /crates/atuin-client/src/register.rs | |
| parent | chore(deps): bump rusty_paseto and rusty_paserk (#2054) (diff) | |
| download | atuin-467f89c104df40904ef4c6b408507e90fe661724.zip | |
feat(ui): add login/register dialog (#2056)
Diffstat (limited to 'crates/atuin-client/src/register.rs')
| -rw-r--r-- | crates/atuin-client/src/register.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/crates/atuin-client/src/register.rs b/crates/atuin-client/src/register.rs new file mode 100644 index 00000000..dae01efd --- /dev/null +++ b/crates/atuin-client/src/register.rs @@ -0,0 +1,23 @@ +use eyre::Result; +use tokio::fs::File; +use tokio::io::AsyncWriteExt; + +use crate::{api_client, settings::Settings}; + +pub async fn register( + settings: &Settings, + username: String, + email: String, + password: String, +) -> Result<String> { + let session = + api_client::register(settings.sync_address.as_str(), &username, &email, &password).await?; + + let path = settings.session_path.as_str(); + let mut file = File::create(path).await?; + file.write_all(session.session.as_bytes()).await?; + + let _key = crate::encryption::load_key(settings)?; + + Ok(session.session) +} |
