feat: implement password fetching for sqlx postgres

This commit is contained in:
realaravinth 2022-05-11 15:43:25 +05:30
parent 6377d07dce
commit fdf4f0bef9
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88

View file

@ -188,6 +188,24 @@ impl MCDatabase for Database {
.map_err(map_register_err)?; .map_err(map_register_err)?;
Ok(()) Ok(())
} }
/// get a user's password
async fn get_password(&self, username: &str) -> DBResult<String> {
struct Password {
password: String,
}
let rec = sqlx::query_as!(
Password,
r#"SELECT password FROM mcaptcha_users WHERE name = ($1)"#,
username,
)
.fetch_one(&self.pool)
.await
.map_err(map_register_err)?;
Ok(rec.password)
}
} }
fn now_unix_time_stamp() -> i64 { fn now_unix_time_stamp() -> i64 {