mirror of
https://github.com/perstarkse/minne.git
synced 2026-03-21 00:49:54 +01:00
feat: gdpr
This commit is contained in:
22
src/server/routes/html/gdpr.rs
Normal file
22
src/server/routes/html/gdpr.rs
Normal 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())
|
||||
}
|
||||
@@ -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(),
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user