Can request password reset
This commit is contained in:
@ -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(
|
||||
|
Reference in New Issue
Block a user