add a ToS switch
This commit is contained in:
parent
57ea39ceda
commit
72abd4d5bd
|
@ -24,6 +24,22 @@ pub async fn upload(form: FormData, ip: Option<IpAddr>, state: SharedState) -> R
|
||||||
.await
|
.await
|
||||||
.map_err(|x| HttpReject::WarpError(x))?;
|
.map_err(|x| HttpReject::WarpError(x))?;
|
||||||
|
|
||||||
|
if let Some(consent) = params.get("tos_consent") {
|
||||||
|
if consent.data != "on".bytes().collect::<Vec<u8>>() {
|
||||||
|
return Ok(
|
||||||
|
Box::new(
|
||||||
|
format!("You need to agree to the ToS to upload a file.\nSee {}/curlapi/help for details\n\nTo agree to the ToS, add a -F'tos_consent=on'\n", state.env.instanceurl)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Ok(
|
||||||
|
Box::new(
|
||||||
|
format!("You need to agree to the ToS to upload a file.\nSee {}/curlapi/help for details\n\nTo agree to the ToS, add a -F'tos_consent=on'\n", state.env.instanceurl)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
let formdata = UploadFormData::from_formdata(params, true);
|
let formdata = UploadFormData::from_formdata(params, true);
|
||||||
if let Some(formdata) = formdata {
|
if let Some(formdata) = formdata {
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ use super::{state::SharedState, pages::{UploadSuccessPage, ErrorPage}, rejection
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Clone)]
|
#[derive(Debug, Serialize, Clone)]
|
||||||
pub struct FormElement {
|
pub struct FormElement {
|
||||||
data: Vec<u8>,
|
pub data: Vec<u8>,
|
||||||
mime: String
|
pub mime: String
|
||||||
}
|
}
|
||||||
impl FormElement {
|
impl FormElement {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue