From 0faf414cd958137ac60a1f37288994f3a1441780 Mon Sep 17 00:00:00 2001 From: TymanWasTaken Date: Mon, 29 Jan 2024 06:17:10 -0500 Subject: feat: Add change-password command & support on server (#1615) * Add change-password command & support on server * Add a test for password change * review: run format --------- Co-authored-by: Ellie Huxtable --- atuin-server-postgres/src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'atuin-server-postgres/src') diff --git a/atuin-server-postgres/src/lib.rs b/atuin-server-postgres/src/lib.rs index c1de4d50..1f7cf47a 100644 --- a/atuin-server-postgres/src/lib.rs +++ b/atuin-server-postgres/src/lib.rs @@ -289,6 +289,22 @@ impl Database for Postgres { Ok(()) } + #[instrument(skip_all)] + async fn update_user_password(&self, user: &User) -> DbResult<()> { + sqlx::query( + "update users + set password = $1 + where id = $2", + ) + .bind(&user.password) + .bind(user.id) + .execute(&self.pool) + .await + .map_err(fix_error)?; + + Ok(()) + } + #[instrument(skip_all)] async fn add_user(&self, user: &NewUser) -> DbResult { let email: &str = &user.email; -- cgit v1.3.1