feat: privacy page and misc templates

This commit is contained in:
Per Stark
2025-01-16 09:14:30 +01:00
parent e58ead5cd7
commit 44ee9b6ce9
10 changed files with 134 additions and 63 deletions

View File

@@ -9,6 +9,7 @@ pub mod gdpr;
pub mod index;
pub mod ingress;
pub mod ingress_tasks;
pub mod privacy_policy;
pub mod search_result;
pub mod signin;
pub mod signout;

View File

@@ -0,0 +1,31 @@
use axum::{extract::State, response::IntoResponse};
use axum_session_auth::AuthSession;
use axum_session_surreal::SessionSurrealPool;
use surrealdb::{engine::any::Any, Surreal};
use crate::{
error::HtmlError,
page_data,
server::{routes::html::render_template, AppState},
storage::types::user::User,
};
page_data!(PrivacyPolicyData, "privacy_policy.html", {
user: Option<User>
});
pub async fn show_privacy_policy(
State(state): State<AppState>,
auth: AuthSession<User, String, SessionSurrealPool<Any>, Surreal<Any>>,
) -> Result<impl IntoResponse, HtmlError> {
let output = render_template(
PrivacyPolicyData::template_name(),
PrivacyPolicyData {
user: auth.current_user,
},
state.templates.clone(),
)
.map_err(|e| HtmlError::from_template_error(e, state.templates.clone()))?;
Ok(output.into_response())
}