use crate::data::error::ResultBoxError; use crate::data::user::User; use crate::helpers::database; use crate::database_structure::USERS_TABLE; /// User helper /// /// @author Pierre Hubert /// Get & return information about a user based on his email pub fn find_user_by_email(email: &str) -> ResultBoxError { exec_get_user_query( database::QueryInfo::new(USERS_TABLE).cond("mail", email)) } /// Execute query & return result fn exec_get_user_query(query : database::QueryInfo) -> ResultBoxError { database::query_row(query, |res|{ Ok(User { id: res.get_int64("ID")?, email: res.get_str("mail")?, password: res.get_str("password")?, first_name: res.get_str("prenom")?, last_name: res.get_str("nom")? }) }) }