Can request password reset

This commit is contained in:
2023-05-31 13:56:18 +02:00
parent 56be33070c
commit 5ed74260a8
4 changed files with 54 additions and 6 deletions

View File

@ -12,12 +12,21 @@ use bcrypt::DEFAULT_COST;
use diesel::prelude::*;
use std::io::ErrorKind;
/// Get the information of the user, by its id
/// Get the information of a user, by its id
pub async fn get_by_id(id: UserID) -> anyhow::Result<User> {
db_connection::execute(|conn| Ok(users::table.filter(users::dsl::id.eq(id.0)).first(conn)?))
}
/// Get the information of the user, by its password reset token
/// Get the information of a user, by its mail
pub async fn get_by_mail(mail: &str) -> anyhow::Result<User> {
db_connection::execute(|conn| {
Ok(users::table
.filter(users::dsl::email.eq(mail))
.first(conn)?)
})
}
/// Get the information of a user, by its password reset token
pub async fn get_by_pwd_reset_token(token: &str) -> anyhow::Result<User> {
if token.is_empty() {
return Err(anyhow::Error::from(std::io::Error::new(