use crate::api_data::login_success::LoginSuccess; use crate::controllers::routes::RequestResult; use crate::data::http_request_handler::HttpRequestHandler; use crate::helpers::account_helper; /// Account controller /// /// @author Pierre Hubert /// Sign in user pub fn login_user(request: &mut HttpRequestHandler) -> RequestResult { let email = request.post_email("userMail")?; let password = request.post_string_opt("userPassword", 3, true)?; // TODO : limit request // Authenticate user let token = account_helper::login_user( &email, &password, request.api_client()); match token { Ok(t) => { request.set_response(LoginSuccess::new(&t)) } Err(e) => { // TODO : limit request println!("Error on login: {}", e); request.forbidden("Invalid email address / password!".to_string()) } } }