feat: implement get secret interface for sqlx postgres

This commit is contained in:
realaravinth 2022-05-11 20:21:33 +05:30
parent 28ddadc5fe
commit 8813cf80ce
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88

View file

@ -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<Secret> {
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 {