refactor: HttpSession/OptionalHttpSession axum extractors
This commit is contained in:
parent
e28c584b26
commit
44c083a8ef
7 changed files with 111 additions and 81 deletions
|
|
@ -3,14 +3,15 @@ use axum::response::{IntoResponse, Redirect, Response};
|
|||
use axum_extra::extract::cookie::CookieJar;
|
||||
|
||||
use crate::db::DatabaseInterface;
|
||||
use crate::http::HttpState;
|
||||
use crate::http::login::{LoginError, login_page};
|
||||
use crate::http::{HttpState, OptionalHttpSession};
|
||||
|
||||
pub async fn logout<D: DatabaseInterface>(
|
||||
State(state): State<HttpState<D>>,
|
||||
session: Option<OptionalHttpSession>,
|
||||
cookies: CookieJar,
|
||||
) -> Response {
|
||||
let Some(session) = state.sessions.get_session(&cookies) else {
|
||||
let Some(session) = session else {
|
||||
return (cookies, Redirect::to("/")).into_response();
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue