mirror of
https://codeberg.org/demostf/frontend.git
synced 2026-08-02 12:24:52 +02:00
This commit is contained in:
parent
3bd791f047
commit
b41f5089f7
1 changed files with 8 additions and 1 deletions
|
|
@ -445,7 +445,14 @@ async fn login(
|
||||||
async fn logout(
|
async fn logout(
|
||||||
State(app): State<Arc<App>>,
|
State(app): State<Arc<App>>,
|
||||||
cookie: Option<TypedHeader<Cookie>>,
|
cookie: Option<TypedHeader<Cookie>>,
|
||||||
|
referrer: Option<TypedHeader<Referer>>,
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
|
let referrer = referrer
|
||||||
|
.map(|TypedHeader(referrer)| referrer.to_string())
|
||||||
|
.map(|referrer| Url::parse(&referrer).ok())
|
||||||
|
.flatten();
|
||||||
|
let return_to = referrer.as_ref().map(|url| url.path()).unwrap_or("/");
|
||||||
|
|
||||||
if let Some(session_cookie) = cookie.as_deref().and_then(|cookie| cookie.get(COOKIE_NAME)) {
|
if let Some(session_cookie) = cookie.as_deref().and_then(|cookie| cookie.get(COOKIE_NAME)) {
|
||||||
if let Ok(Some(cookie)) = app.session_store.load_session(session_cookie.into()).await {
|
if let Ok(Some(cookie)) = app.session_store.load_session(session_cookie.into()).await {
|
||||||
let _ = app.session_store.destroy_session(cookie).await;
|
let _ = app.session_store.destroy_session(cookie).await;
|
||||||
|
|
@ -462,7 +469,7 @@ async fn logout(
|
||||||
))
|
))
|
||||||
.expect("invalid cookie"),
|
.expect("invalid cookie"),
|
||||||
),
|
),
|
||||||
(LOCATION, HeaderValue::from_str("/").unwrap()),
|
(LOCATION, HeaderValue::from_str(return_to).unwrap()),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue