feat: impl def_email for sqlx postgres
This commit is contained in:
parent
6e45c643b1
commit
38d518d843
1 changed files with 17 additions and 0 deletions
|
@ -155,6 +155,23 @@ impl MCDatabase for Database {
|
|||
Ok(resp)
|
||||
}
|
||||
|
||||
/// get user email
|
||||
async fn get_email(&self, username: &str) -> DBResult<Option<String>> {
|
||||
struct Email {
|
||||
email: Option<String>,
|
||||
}
|
||||
|
||||
let res = sqlx::query_as!(
|
||||
Email,
|
||||
"SELECT email FROM mcaptcha_users WHERE name = $1",
|
||||
username
|
||||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::AccountNotFound))?;
|
||||
Ok(res.email)
|
||||
}
|
||||
|
||||
/// check if email exists
|
||||
async fn email_exists(&self, email: &str) -> DBResult<bool> {
|
||||
let res = sqlx::query!(
|
||||
|
|
Loading…
Reference in a new issue