diff --git a/src/main.rs b/src/main.rs index 7f85990..ab2a079 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,6 +31,11 @@ struct DirPath { name: String, } +#[derive(FromForm)] +struct DirName { + name: String +} + #[derive(Debug, FromForm, Deserialize)] struct GenericUser { key: String, @@ -46,9 +51,11 @@ impl<'a, 'r> FromRequest<'a, 'r> for GenericUser { Some(key) => { if key.value() == ADMIN_KEY.as_str() || key.value() == USER_KEY.as_str() { request::Outcome::Success(GenericUser { key: String::from(key.value()) }) + } else if *PUBLIC_READ { + request::Outcome::Success(GenericUser { key: String::from("") }) } else { request::Outcome::Failure((Status::BadRequest, ())) - } + } }, None => { if *PUBLIC_READ { @@ -70,10 +77,10 @@ impl<'a, 'r> FromRequest<'a, 'r> for AdminUser { if key.value() == ADMIN_KEY.as_str() { request::Outcome::Success(AdminUser) } else { - request::Outcome::Failure((Status::BadRequest, ())) + request::Outcome::Forward(()) } }, - None => request::Outcome::Failure((Status::BadRequest, ())) + None => request::Outcome::Forward(()) } } } @@ -86,7 +93,6 @@ fn root() -> Template { #[post("/login", data = "