From 374bbb24034aed45bd212c9083e44e65f0c0fc95 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Wed, 11 May 2022 19:51:39 +0530 Subject: [PATCH] feat: implement change password for sqlx postgres --- db/db-sqlx-postgres/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/db/db-sqlx-postgres/src/lib.rs b/db/db-sqlx-postgres/src/lib.rs index b7ee9d92..82c8fe31 100644 --- a/db/db-sqlx-postgres/src/lib.rs +++ b/db/db-sqlx-postgres/src/lib.rs @@ -222,6 +222,21 @@ impl MCDatabase for Database { Ok(res) } + + /// update user's password + async fn update_password(&self, p: &NameHash) -> DBResult<()> { + sqlx::query!( + "UPDATE mcaptcha_users set password = $1 + WHERE name = $2", + &p.hash, + &p.username, + ) + .execute(&self.pool) + .await + .map_err(map_register_err)?; + + Ok(()) + } } fn now_unix_time_stamp() -> i64 {