linted the code.
This commit is contained in:
1 parent
0c171171c2
commit
f4170610b0
12 files changed
+84
-57
No files matched your search
+13
-9
@@ -1,6 +1,6 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use actix_web::{error, HttpRequest, Responder, web};
|
||||
use actix_web::{error, web, HttpRequest, Responder};
|
||||
use clap::builder::TypedValueParser;
|
||||
use log::info;
|
||||
use minijinja::context;
|
||||
@@ -23,8 +23,10 @@ pub async fn actions(tmpl_env: MiniJinjaRenderer) -> actix_web::Result<impl Resp
|
||||
}
|
||||
|
||||
#[actix_web::get("/overview")]
|
||||
pub async fn overview(tmpl_env: MiniJinjaRenderer,
|
||||
connFactory: web::Data<SQLiteConnectionFactory>) -> actix_web::Result<impl Responder> {
|
||||
pub async fn overview(
|
||||
tmpl_env: MiniJinjaRenderer,
|
||||
connFactory: web::Data<SQLiteConnectionFactory>,
|
||||
) -> actix_web::Result<impl Responder> {
|
||||
let conn = connFactory.readonly().unwrap(); // todo; to proper 500
|
||||
let service_factory = ServiceFactory::new(&conn);
|
||||
let user_service = service_factory.get_user_service();
|
||||
@@ -41,10 +43,11 @@ struct LoginPayload {
|
||||
password: String,
|
||||
}
|
||||
|
||||
|
||||
#[actix_web::post("/login")]
|
||||
pub async fn login(tmpl_env: MiniJinjaRenderer,
|
||||
web::Json(form): web::Json<LoginPayload>) -> actix_web::Result<impl Responder> {
|
||||
pub async fn login(
|
||||
tmpl_env: MiniJinjaRenderer,
|
||||
web::Json(form): web::Json<LoginPayload>,
|
||||
) -> actix_web::Result<impl Responder> {
|
||||
let ctx = context! {
|
||||
name => form.username,
|
||||
};
|
||||
@@ -55,7 +58,9 @@ pub async fn login(tmpl_env: MiniJinjaRenderer,
|
||||
pub async fn logout(tmpl_env: MiniJinjaRenderer) -> actix_web::Result<impl Responder> {
|
||||
let ctx = context! {};
|
||||
let res = tmpl_env.render("partials/index/form.html", ctx)?;
|
||||
Ok(res.customize().insert_header(("Set-Cookie", "username=nobody")))
|
||||
Ok(res
|
||||
.customize()
|
||||
.insert_header(("Set-Cookie", "username=nobody")))
|
||||
}
|
||||
|
||||
#[actix_web::get("/partials/overview/submit_button")]
|
||||
@@ -86,7 +91,6 @@ pub async fn actions_partials(
|
||||
tmpl_env.render(template_location.as_str(), ctx)
|
||||
}
|
||||
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct CreateEventPayload {
|
||||
event: Event,
|
||||
@@ -102,7 +106,7 @@ pub async fn push_event(
|
||||
) -> actix_web::Result<impl Responder> {
|
||||
let path_event_type = req.match_info().get("event_type").unwrap();
|
||||
if path_event_type.to_string() != form.event_type {
|
||||
return Err(error::ErrorBadRequest("Inconsistent event type."))
|
||||
return Err(error::ErrorBadRequest("Inconsistent event type."));
|
||||
}
|
||||
let validation = form.event.validate_event();
|
||||
if validation.is_err() {
|
||||
|
||||
Reference in new issue
Block a user