1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-29 22:01:14 +03:00

Fix the login template not rendering on policy error

This commit is contained in:
Quentin Gliech
2023-11-03 16:39:00 +01:00
parent a2f8d81107
commit 18259a6412
4 changed files with 30 additions and 8 deletions

View File

@ -32,7 +32,7 @@ use ulid::Ulid;
use url::Url;
pub use self::branding::SiteBranding;
use crate::{FormField, FormState};
use crate::{FieldError, FormField, FormState};
/// Helper trait to construct context wrappers
pub trait TemplateContext: Serialize {
@ -408,6 +408,26 @@ impl TemplateContext for LoginContext {
password_disabled: false,
providers: Vec::new(),
},
LoginContext {
form: FormState::default()
.with_error_on_field(LoginFormField::Username, FieldError::Required)
.with_error_on_field(
LoginFormField::Password,
FieldError::Policy {
message: "password too short".to_owned(),
},
),
next: None,
password_disabled: false,
providers: Vec::new(),
},
LoginContext {
form: FormState::default()
.with_error_on_field(LoginFormField::Username, FieldError::Exists),
next: None,
password_disabled: false,
providers: Vec::new(),
},
]
}
}