From 8813cf80ce5d0703197be3b5bef07fde055ec511 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Wed, 11 May 2022 20:21:33 +0530 Subject: [PATCH] feat: implement get secret interface for sqlx postgres --- db/db-sqlx-postgres/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/db/db-sqlx-postgres/src/lib.rs b/db/db-sqlx-postgres/src/lib.rs index 0250378d..db3df1b5 100644 --- a/db/db-sqlx-postgres/src/lib.rs +++ b/db/db-sqlx-postgres/src/lib.rs @@ -250,6 +250,20 @@ impl MCDatabase for Database { .map_err(map_register_err)?; Ok(()) } + + /// get a user's secret + async fn get_secret(&self, username: &str) -> DBResult { + let secret = sqlx::query_as!( + Secret, + r#"SELECT secret FROM mcaptcha_users WHERE name = ($1)"#, + username, + ) + .fetch_one(&self.pool) + .await + .map_err(map_register_err)?; + + Ok(secret) + } } fn now_unix_time_stamp() -> i64 {