Compare commits
2 Commits
ff7324d089
...
6471a7b8d5
Author | SHA1 | Date |
---|---|---|
blek | 6471a7b8d5 | |
blek | 41e98c2245 |
|
@ -13,9 +13,9 @@ use serde::Serialize;
|
||||||
|
|
||||||
use crate::files::{File, lookup::LookupKind, DeleteMode};
|
use crate::files::{File, lookup::LookupKind, DeleteMode};
|
||||||
|
|
||||||
use super::{state::SharedState, pages::{BadActionReq, UploadSuccessPage}, rejection::HttpReject};
|
use super::{state::SharedState, pages::{BadActionReq, UploadSuccessPage, self}, rejection::HttpReject};
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Clone)]
|
||||||
struct FormElement {
|
struct FormElement {
|
||||||
data: Vec<u8>,
|
data: Vec<u8>,
|
||||||
mime: String
|
mime: String
|
||||||
|
@ -67,7 +67,31 @@ pub async fn upload(form: FormData, state: SharedState) -> Result<Box<dyn Reply>
|
||||||
let delmode = params.get("delmode").unwrap();
|
let delmode = params.get("delmode").unwrap();
|
||||||
let named = params.get("named");
|
let named = params.get("named");
|
||||||
let filename = params.get("filename").unwrap();
|
let filename = params.get("filename").unwrap();
|
||||||
|
let tos_check = match params.get("tos_consent") {
|
||||||
|
Some(v) => (*v).clone(),
|
||||||
|
None => FormElement { data: "off".as_bytes().to_vec(), mime: "text/plain".into() }
|
||||||
|
};
|
||||||
let mut is_named = named.is_none();
|
let mut is_named = named.is_none();
|
||||||
|
let tos_check = tos_check.as_str_or_reject()?;
|
||||||
|
if tos_check != "on" {
|
||||||
|
return Ok(
|
||||||
|
Box::new(
|
||||||
|
warp::reply::html(
|
||||||
|
pages::ErrorPage {
|
||||||
|
env: state.env,
|
||||||
|
error_text: "You must consent to the terms and conditions!".into(),
|
||||||
|
link: Some("/".into()),
|
||||||
|
link_text: Some("Go back".into())
|
||||||
|
}
|
||||||
|
.render()
|
||||||
|
.map_err(
|
||||||
|
|err|
|
||||||
|
warp::reject::custom(HttpReject::AskamaError(err))
|
||||||
|
)?
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
let delmode = delmode.as_str_or_reject()?;
|
let delmode = delmode.as_str_or_reject()?;
|
||||||
if delmode != "30" && delmode != "dl" {
|
if delmode != "30" && delmode != "dl" {
|
||||||
|
|
|
@ -68,6 +68,17 @@ pub struct TOSPage {
|
||||||
pub env: Env
|
pub env: Env
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Template)]
|
||||||
|
#[template( path = "error.html" )]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub struct ErrorPage {
|
||||||
|
pub env: Env,
|
||||||
|
pub error_text: String,
|
||||||
|
pub link: Option<String>,
|
||||||
|
pub link_text: Option<String>
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn uploaded(query: HashMap<String, String>, state: SharedState) -> Result<Html<String>, Rejection> {
|
pub async fn uploaded(query: HashMap<String, String>, state: SharedState) -> Result<Html<String>, Rejection> {
|
||||||
|
|
||||||
if ! query.contains_key("file") {
|
if ! query.contains_key("file") {
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
<div style="max-width:95vw;width:fit-content;margin:0 auto">
|
||||||
|
<h1 style="text-align:center">Error</h1>
|
||||||
|
|
||||||
|
<p style='text-align:center'>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="52" height="52" fill="currentColor" class="bi bi-x-lg" viewBox="0 0 16 16">
|
||||||
|
<path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/>
|
||||||
|
</svg>
|
||||||
|
</p>
|
||||||
|
<p>{{ error_text }}</p>
|
||||||
|
{% match link %}
|
||||||
|
{% when Some with (lnk) %}
|
||||||
|
<a href="{{ lnk }}" class="btn btn-fill" style="display:block">
|
||||||
|
{% match link_text %}
|
||||||
|
{% when Some with (text) %}
|
||||||
|
{{ text }}
|
||||||
|
{% when None %}
|
||||||
|
Go to {{ lnk }}
|
||||||
|
{% endmatch %}
|
||||||
|
</a>
|
||||||
|
{% when None -%}
|
||||||
|
{% endmatch %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue