1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-29 08:46:27 +00:00

Start to implement login method

This commit is contained in:
Pierre HUBERT 2020-05-21 15:43:53 +02:00
parent 9b7bf77a0a
commit ab5df69ee5
3 changed files with 29 additions and 4 deletions

View File

@ -0,0 +1,11 @@
use crate::data::http_request_handler::HttpRequestHandler;
use crate::controllers::routes::RequestResult;
/// Account controller
///
/// @author Pierre Hubert
/// Sign in user
pub fn login_user(request: &mut HttpRequestHandler) -> RequestResult {
request.success("Login user")
}

View File

@ -2,3 +2,4 @@ pub mod routes;
pub mod server; pub mod server;
pub mod server_controller; pub mod server_controller;
pub mod account_controller;

View File

@ -1,7 +1,7 @@
use std::error::Error; use std::error::Error;
use crate::controllers::routes::Method::GET; use crate::controllers::routes::Method::{GET, POST};
use crate::controllers::server_controller; use crate::controllers::{server_controller, account_controller};
use crate::data::http_request_handler::HttpRequestHandler; use crate::data::http_request_handler::HttpRequestHandler;
/// Project routes /// Project routes
@ -42,12 +42,25 @@ impl Route {
func func
} }
} }
pub fn post_without_login(uri: &'static str, func: RequestProcess) -> Route {
Route {
method: POST,
need_login: false,
uri,
func
}
}
} }
/// Get the list of routes available /// Get the list of routes available
pub fn get_routes() -> Vec<Route> { pub fn get_routes() -> Vec<Route> {
vec![ vec![
// Server meta routes // Server meta routes
Route::get_without_login("/", Box::new(server_controller::main_index)) Route::get_without_login("/", Box::new(server_controller::main_index)),
// Account controller
Route::post_without_login("/account/login", Box::new(account_controller::login_user)),
Route::post_without_login("/account/connectUSER", Box::new(account_controller::login_user)),
] ]
} }