HX-Redirect to handle redirections with htmx

This commit is contained in:
Alphonse Paix
2025-09-17 13:16:56 +02:00
parent 7689628ffb
commit 7364e2a23c
8 changed files with 41 additions and 95 deletions

View File

@@ -1,8 +1,9 @@
pub mod change_password;
pub mod dashboard;
pub mod newsletters;
mod change_password;
mod dashboard;
mod logout;
mod newsletters;
use crate::{routes::error_chain_fmt, session_state::TypedSession, templates::ErrorTemplate};
use crate::{routes::error_chain_fmt, templates::ErrorTemplate};
use askama::Template;
use axum::{
Json,
@@ -10,6 +11,7 @@ use axum::{
};
pub use change_password::*;
pub use dashboard::*;
pub use logout::*;
pub use newsletters::*;
use reqwest::StatusCode;
@@ -69,9 +71,3 @@ impl IntoResponse for AdminError {
}
}
}
#[tracing::instrument(name = "Logging out", skip(session))]
pub async fn logout(session: TypedSession) -> Result<Response, AdminError> {
session.clear().await;
Ok(Redirect::to("/login").into_response())
}