mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2024-11-26 19:36:01 +03:00
feat: implement username exists for postgres via sqlx
This commit is contained in:
parent
e244713ad7
commit
79cc28bfd8
1 changed files with 18 additions and 0 deletions
|
@ -138,6 +138,24 @@ impl MCDatabase for Database {
|
|||
.map_err(map_register_err)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// check if username exists
|
||||
async fn username_exists(&self, username: &str) -> DBResult<bool> {
|
||||
let res = sqlx::query!(
|
||||
"SELECT EXISTS (SELECT 1 from mcaptcha_users WHERE name = $1)",
|
||||
username,
|
||||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await
|
||||
.map_err(map_register_err)?;
|
||||
|
||||
let mut resp = false;
|
||||
if let Some(x) = res.exists {
|
||||
resp = x;
|
||||
}
|
||||
|
||||
Ok(resp)
|
||||
}
|
||||
}
|
||||
|
||||
fn now_unix_time_stamp() -> i64 {
|
||||
|
|
Loading…
Reference in a new issue