Brought back newsletter form on admin page

This commit is contained in:
Alphonse Paix
2025-09-18 18:40:03 +02:00
parent 54218f92a9
commit 08d5f611b5
5 changed files with 85 additions and 16 deletions

View File

@@ -58,7 +58,8 @@ impl IntoResponse for AdminError {
AdminError::NotAuthenticated => {
let mut headers = HeaderMap::new();
headers.insert("HX-Redirect", "/login".parse().unwrap());
(StatusCode::OK, headers).into_response()
headers.insert("Location", "/login".parse().unwrap());
(StatusCode::SEE_OTHER, headers).into_response()
}
AdminError::ChangePassword(e) => {
let template = ErrorTemplate {

View File

@@ -10,16 +10,19 @@ use uuid::Uuid;
#[template(path = "../templates/dashboard.html")]
struct DashboardTemplate {
username: String,
idempotency_key: String,
idempotency_key_1: String,
idempotency_key_2: String,
}
pub async fn admin_dashboard(
Extension(AuthenticatedUser { username, .. }): Extension<AuthenticatedUser>,
) -> Response {
let idempotency_key = Uuid::new_v4().to_string();
let idempotency_key_1 = Uuid::new_v4().to_string();
let idempotency_key_2 = Uuid::new_v4().to_string();
let template = DashboardTemplate {
username,
idempotency_key,
idempotency_key_1,
idempotency_key_2,
};
Html(template.render().unwrap()).into_response()
}

View File

@@ -10,5 +10,6 @@ pub async fn logout(session: TypedSession) -> Result<Response, AdminError> {
session.clear().await;
let mut headers = HeaderMap::new();
headers.insert("HX-Redirect", "/login".parse().unwrap());
Ok((StatusCode::OK, headers).into_response())
headers.insert("Location", "/login".parse().unwrap());
Ok((StatusCode::SEE_OTHER, headers).into_response())
}