feat: improved ingress form and account settings

This commit is contained in:
Per Stark
2025-01-22 08:53:23 +01:00
parent 14e548c26f
commit d6a2139f4c
7 changed files with 56 additions and 41 deletions

View File

@@ -17,7 +17,7 @@ use crate::{
use super::render_block;
page_data!(AccountData, "auth/account.html", {
page_data!(AccountData, "auth/account_settings.html", {
user: User
});

View File

@@ -46,6 +46,8 @@ pub struct IngressParams {
page_data!(IngressFormData, "ingress_form.html", {
instructions: String,
content: String,
category: String,
error: String,
});
pub async fn process_ingress_form(
@@ -56,15 +58,6 @@ pub async fn process_ingress_form(
let user = auth.current_user.ok_or_else(|| {
AppError::Auth("You must be signed in".to_string()).with_template(state.templates.clone())
})?;
// let user = match auth.current_user {
// Some(user) => user,
// None => {
// return Err(HtmlError::new(
// AppError::Auth("You must be signed in".to_string()),
// state.templates,
// ))
// }
// };
if input.content.clone().is_some_and(|c| c.len() < 2) && input.files.is_empty() {
let output = render_template(
@@ -72,17 +65,13 @@ pub async fn process_ingress_form(
IngressFormData {
instructions: input.instructions.clone(),
content: input.content.clone().unwrap(),
category: input.category.clone(),
error: "You need to either add files or content".to_string(),
},
state.templates.clone(),
)?;
return Ok(output.into_response());
// return Ok((
// StatusCode::UNAUTHORIZED,
// Html("Invalid input, make sure you fill in either content or add files"),
// )
// .into_response());
}
info!("{:?}", input);