mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2024-11-27 03:48:52 +03:00
feat: implement get secret interface for sqlx postgres
This commit is contained in:
parent
28ddadc5fe
commit
8813cf80ce
1 changed files with 14 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue