mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-25 23:09:22 +00:00
Start to implement login method
This commit is contained in:
parent
9b7bf77a0a
commit
ab5df69ee5
11
src/controllers/account_controller.rs
Normal file
11
src/controllers/account_controller.rs
Normal 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")
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
pub mod routes;
|
pub mod routes;
|
||||||
pub mod server;
|
pub mod server;
|
||||||
|
|
||||||
pub mod server_controller;
|
pub mod server_controller;
|
||||||
|
pub mod account_controller;
|
@ -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)),
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user