Run 'cargo fmt' to format code (#489)
This commit is contained in:
committed by
Baptiste Gelez
parent
732f514da7
commit
b945d1f602
+43
-25
@@ -1,11 +1,11 @@
|
||||
use plume_models::users::User;
|
||||
use plume_models::{db_conn::DbConn, Error};
|
||||
use rocket::{
|
||||
Request,
|
||||
request::FromRequest,
|
||||
response::{self, Responder},
|
||||
Request,
|
||||
};
|
||||
use rocket_i18n::I18n;
|
||||
use plume_models::{Error, db_conn::DbConn};
|
||||
use plume_models::users::User;
|
||||
use template_utils::Ructe;
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -24,15 +24,24 @@ impl<'r> Responder<'r> for ErrorPage {
|
||||
let user = User::from_request(req).succeeded();
|
||||
|
||||
match self.0 {
|
||||
Error::NotFound => render!(errors::not_found(
|
||||
&(&*conn.unwrap(), &intl.unwrap().catalog, user)
|
||||
)).respond_to(req),
|
||||
Error::Unauthorized => render!(errors::not_found(
|
||||
&(&*conn.unwrap(), &intl.unwrap().catalog, user)
|
||||
)).respond_to(req),
|
||||
_ => render!(errors::not_found(
|
||||
&(&*conn.unwrap(), &intl.unwrap().catalog, user)
|
||||
)).respond_to(req)
|
||||
Error::NotFound => render!(errors::not_found(&(
|
||||
&*conn.unwrap(),
|
||||
&intl.unwrap().catalog,
|
||||
user
|
||||
)))
|
||||
.respond_to(req),
|
||||
Error::Unauthorized => render!(errors::not_found(&(
|
||||
&*conn.unwrap(),
|
||||
&intl.unwrap().catalog,
|
||||
user
|
||||
)))
|
||||
.respond_to(req),
|
||||
_ => render!(errors::not_found(&(
|
||||
&*conn.unwrap(),
|
||||
&intl.unwrap().catalog,
|
||||
user
|
||||
)))
|
||||
.respond_to(req),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,9 +51,11 @@ pub fn not_found(req: &Request) -> Ructe {
|
||||
let conn = req.guard::<DbConn>().succeeded();
|
||||
let intl = req.guard::<I18n>().succeeded();
|
||||
let user = User::from_request(req).succeeded();
|
||||
render!(errors::not_found(
|
||||
&(&*conn.unwrap(), &intl.unwrap().catalog, user)
|
||||
))
|
||||
render!(errors::not_found(&(
|
||||
&*conn.unwrap(),
|
||||
&intl.unwrap().catalog,
|
||||
user
|
||||
)))
|
||||
}
|
||||
|
||||
#[catch(422)]
|
||||
@@ -52,9 +63,11 @@ pub fn unprocessable_entity(req: &Request) -> Ructe {
|
||||
let conn = req.guard::<DbConn>().succeeded();
|
||||
let intl = req.guard::<I18n>().succeeded();
|
||||
let user = User::from_request(req).succeeded();
|
||||
render!(errors::unprocessable_entity(
|
||||
&(&*conn.unwrap(), &intl.unwrap().catalog, user)
|
||||
))
|
||||
render!(errors::unprocessable_entity(&(
|
||||
&*conn.unwrap(),
|
||||
&intl.unwrap().catalog,
|
||||
user
|
||||
)))
|
||||
}
|
||||
|
||||
#[catch(500)]
|
||||
@@ -62,17 +75,22 @@ pub fn server_error(req: &Request) -> Ructe {
|
||||
let conn = req.guard::<DbConn>().succeeded();
|
||||
let intl = req.guard::<I18n>().succeeded();
|
||||
let user = User::from_request(req).succeeded();
|
||||
render!(errors::server_error(
|
||||
&(&*conn.unwrap(), &intl.unwrap().catalog, user)
|
||||
))
|
||||
render!(errors::server_error(&(
|
||||
&*conn.unwrap(),
|
||||
&intl.unwrap().catalog,
|
||||
user
|
||||
)))
|
||||
}
|
||||
|
||||
#[post("/csrf-violation?<target>")]
|
||||
pub fn csrf_violation(target: Option<String>, conn: DbConn, intl: I18n, user: Option<User>) -> Ructe {
|
||||
pub fn csrf_violation(
|
||||
target: Option<String>,
|
||||
conn: DbConn,
|
||||
intl: I18n,
|
||||
user: Option<User>,
|
||||
) -> Ructe {
|
||||
if let Some(uri) = target {
|
||||
eprintln!("Csrf violation while acceding \"{}\"", uri)
|
||||
}
|
||||
render!(errors::csrf(
|
||||
&(&*conn, &intl.catalog, user)
|
||||
))
|
||||
render!(errors::csrf(&(&*conn, &intl.catalog, user)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user