Fix login/signup redirection

HTMX needs special treatment for redirects on submit.
This commit is contained in:
2023-09-26 01:48:05 -04:00
parent 6fd2f150a0
commit 81b4ef860e
4 changed files with 39 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
use axum::response::{IntoResponse, Redirect, Response};
use axum::response::{IntoResponse, Response};
use axum::{extract::State, Form};
use maud::html;
use serde::Deserialize;
@@ -6,6 +6,7 @@ use serde_with::{serde_as, NoneAsEmptyString};
use sqlx::PgPool;
use crate::error::{Error, Result};
use crate::htmx::HXRedirect;
use crate::models::user::{AuthContext, CreateUser, User};
use crate::partials::layout::Layout;
use crate::partials::signup_form::{signup_form, SignupFormProps};
@@ -107,5 +108,5 @@ pub async fn post(
auth.login(&user)
.await
.map_err(|_| Error::InternalServerError)?;
Ok(Redirect::to("/").into_response())
Ok(HXRedirect::to("/").into_response())
}