Skip to content

Commit

Permalink
fix: add Hx-Request render path for login form
Browse files Browse the repository at this point in the history
  • Loading branch information
jdevries3133 committed Jun 29, 2024
1 parent 0949d04 commit 119b833
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/auth/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,16 @@ pub async fn get_login_form(
headers: HeaderMap,
) -> Result<impl IntoResponse, ServerError> {
let session = Session::from_headers(&headers);
let form = Page {
title: "Login",
children: &PageContainer {
children: &LoginForm {},
},
let form = if headers.contains_key("Hx-Request") {
LoginForm {}.render()
} else {
Page {
title: "Login",
children: &PageContainer {
children: &LoginForm {},
},
}
.render()
};
Ok(match session {
Some(session) => {
Expand All @@ -100,10 +105,10 @@ pub async fn get_login_form(

(StatusCode::SEE_OTHER, headers).into_response()
} else {
form.render().into_response()
form.into_response()
}
}
None => form.render().into_response(),
None => form.into_response(),
})
}

Expand Down

0 comments on commit 119b833

Please sign in to comment.