mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2024-11-23 18:05:54 +03:00
feat: implement password fetching for sqlx postgres
This commit is contained in:
parent
6377d07dce
commit
fdf4f0bef9
1 changed files with 18 additions and 0 deletions
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue