aboutsummaryrefslogtreecommitdiffstats
path: root/crates/atuin-client/src/register.rs
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2024-05-30 12:49:22 +0100
committerGitHub <noreply@github.com>2024-05-30 12:49:22 +0100
commit467f89c104df40904ef4c6b408507e90fe661724 (patch)
treee93697bdfa14ca6b083b0ea02c85d1d0688e0eba /crates/atuin-client/src/register.rs
parentchore(deps): bump rusty_paseto and rusty_paserk (#2054) (diff)
downloadatuin-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.rs23
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)
+}