feat: gdpr

This commit is contained in:
Per Stark
2025-01-02 22:43:32 +01:00
parent 9976fef5a3
commit ab23909e0f
8 changed files with 2901 additions and 3 deletions

View File

@@ -0,0 +1,22 @@
use axum::response::{Html, IntoResponse};
use axum_session::Session;
use axum_session_surreal::SessionSurrealPool;
use surrealdb::engine::any::Any;
use crate::error::HtmlError;
pub async fn accept_gdpr(
session: Session<SessionSurrealPool<Any>>,
) -> Result<impl IntoResponse, HtmlError> {
session.set("gdpr_accepted", true);
Ok(Html("").into_response())
}
pub async fn deny_gdpr(
session: Session<SessionSurrealPool<Any>>,
) -> Result<impl IntoResponse, HtmlError> {
session.set("gdpr_accepted", true);
Ok(Html("").into_response())
}

View File

@@ -1,4 +1,5 @@
use axum::{extract::State, response::IntoResponse};
use axum_session::Session;
use axum_session_auth::AuthSession;
use axum_session_surreal::SessionSurrealPool;
use surrealdb::{engine::any::Any, Surreal};
@@ -12,6 +13,7 @@ use crate::{
};
page_data!(IndexData, "index/index.html", {
gdpr_accepted: bool,
queue_length: u32,
user: Option<User>
});
@@ -19,9 +21,12 @@ page_data!(IndexData, "index/index.html", {
pub async fn index_handler(
State(state): State<AppState>,
auth: AuthSession<User, String, SessionSurrealPool<Any>, Surreal<Any>>,
session: Session<SessionSurrealPool<Any>>,
) -> Result<impl IntoResponse, HtmlError> {
info!("Displaying index page");
let gdpr_accepted = auth.current_user.is_some() | session.get("gdpr_accepted").unwrap_or(false);
let queue_length = state
.rabbitmq_consumer
.get_queue_length()
@@ -40,6 +45,7 @@ pub async fn index_handler(
IndexData::template_name(),
IndexData {
queue_length,
gdpr_accepted,
user: auth.current_user,
},
state.templates.clone(),

View File

@@ -4,6 +4,7 @@ use axum::response::Html;
use minijinja_autoreload::AutoReloader;
pub mod account;
pub mod gdpr;
pub mod index;
pub mod ingress;
pub mod search_result;