mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-30 01:06:27 +00:00
Start to implement new route
This commit is contained in:
parent
071c773412
commit
515f8d2ffc
@ -2,13 +2,27 @@ use crate::api_data::current_user_id::CurrentUserID;
|
||||
use crate::api_data::login_success::LoginSuccess;
|
||||
use crate::api_data::res_check_email_exists::ResCheckEmailExists;
|
||||
use crate::controllers::routes::RequestResult;
|
||||
use crate::data::error::ResultBoxError;
|
||||
use crate::data::http_request_handler::HttpRequestHandler;
|
||||
use crate::helpers::account_helper;
|
||||
use crate::data::user::User;
|
||||
use crate::helpers::{account_helper, user_helper};
|
||||
|
||||
/// Account controller
|
||||
///
|
||||
/// @author Pierre Hubert
|
||||
|
||||
impl HttpRequestHandler {
|
||||
/// Get information about a user based on its email address specified in the request
|
||||
pub fn post_user_info_from_email(&mut self, field: &str) -> ResultBoxError<User> {
|
||||
let email = self.post_email(field)?;
|
||||
|
||||
self.ok_or_not_found(
|
||||
user_helper::find_user_by_email(&email),
|
||||
format!("Requested user in '{}' not found!", email).as_str(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Sign in user
|
||||
pub fn login_user(request: &mut HttpRequestHandler) -> RequestResult {
|
||||
let email = request.post_email("userMail")?;
|
||||
@ -60,3 +74,12 @@ pub fn exists_mail(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
|
||||
r.set_response(ResCheckEmailExists::new(account_helper::exists_mail(&email)?))
|
||||
}
|
||||
|
||||
/// Check out whether a given user has set security questions or not
|
||||
pub fn has_security_questions(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let user = r.post_user_info_from_email("email")?;
|
||||
|
||||
// TODO : continue implementation
|
||||
println!("{:#?}", user);
|
||||
r.success("implement me")
|
||||
}
|
@ -75,6 +75,7 @@ pub fn get_routes() -> Vec<Route> {
|
||||
Route::post("/account/id", Box::new(account_controller::user_id)),
|
||||
Route::post("/user/getCurrentUserID", Box::new(account_controller::user_id)),
|
||||
Route::post_without_login("/account/exists_email", Box::new(account_controller::exists_mail)),
|
||||
Route::post_without_login("/account/has_security_questions", Box::new(account_controller::has_security_questions)),
|
||||
|
||||
// User controller
|
||||
Route::post_without_login("/user/getInfo", Box::new(user_controller::get_single)),
|
||||
|
Loading…
Reference in New Issue
Block a user