You've already forked AstralRinth
forked from didirus/AstralRinth
feat(labrinth): ignore email case differences in password recovery flow (#3771)
* feat(labrinth): ignore email case differences in password recovery flow * chore(labrinth): run `sqlx prepare`
This commit is contained in:
committed by
GitHub
parent
a2e323c9ee
commit
ee8ee7af82
@@ -224,24 +224,46 @@ impl DBUser {
|
||||
Ok(val)
|
||||
}
|
||||
|
||||
pub async fn get_email<'a, E>(
|
||||
pub async fn get_by_email<'a, E>(
|
||||
email: &str,
|
||||
exec: E,
|
||||
) -> Result<Option<DBUserId>, sqlx::Error>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
{
|
||||
let user_pass = sqlx::query!(
|
||||
let user = sqlx::query!(
|
||||
"
|
||||
SELECT id FROM users
|
||||
WHERE email = $1
|
||||
",
|
||||
email
|
||||
)
|
||||
.map(|row| DBUserId(row.id))
|
||||
.fetch_optional(exec)
|
||||
.await?;
|
||||
|
||||
Ok(user_pass.map(|x| DBUserId(x.id)))
|
||||
Ok(user)
|
||||
}
|
||||
|
||||
pub async fn get_by_case_insensitive_email<'a, E>(
|
||||
email: &str,
|
||||
exec: E,
|
||||
) -> Result<Vec<DBUserId>, sqlx::Error>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
{
|
||||
let users = sqlx::query!(
|
||||
"
|
||||
SELECT id FROM users
|
||||
WHERE LOWER(email) = LOWER($1)
|
||||
",
|
||||
email
|
||||
)
|
||||
.map(|row| DBUserId(row.id))
|
||||
.fetch_all(exec)
|
||||
.await?;
|
||||
|
||||
Ok(users)
|
||||
}
|
||||
|
||||
pub async fn get_projects<'a, E>(
|
||||
|
||||
Reference in New Issue
Block a user