Confirmation page and minor improvements to homepage and form messages
Basic redirect with flash messages for success and error messages
This commit is contained in:
@@ -13,7 +13,6 @@ use axum::{
|
||||
use axum_messages::Messages;
|
||||
use reqwest::StatusCode;
|
||||
use secrecy::SecretString;
|
||||
use std::fmt::Write;
|
||||
|
||||
#[derive(thiserror::Error)]
|
||||
pub enum LoginError {
|
||||
@@ -54,7 +53,7 @@ impl IntoResponse for LoginError {
|
||||
#[derive(Template)]
|
||||
#[template(path = "../templates/login.html")]
|
||||
struct LoginTemplate {
|
||||
error_html: String,
|
||||
error: String,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
@@ -64,11 +63,12 @@ pub struct LoginFormData {
|
||||
}
|
||||
|
||||
pub async fn get_login(messages: Messages) -> Html<String> {
|
||||
let mut error_html = String::new();
|
||||
for message in messages {
|
||||
writeln!(error_html, "<p><i>{}</i></p>", message).unwrap();
|
||||
}
|
||||
let template = LoginTemplate { error_html };
|
||||
let template = LoginTemplate {
|
||||
error: messages
|
||||
.last()
|
||||
.map(|msg| msg.to_string())
|
||||
.unwrap_or_default(),
|
||||
};
|
||||
Html(template.render().unwrap())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user