Email blocklisting (#718)

* Interface complete for the email blacklisting

* Everything seems to work

* Neutralize language

* fix clippy warnings

* Add missing spaces

* Added matching test

* Correct primary key datatype for postgresql

* Address review comments

* Add placeholder when empty. Fix missing 'i'
This commit is contained in:
Violet White
2020-01-12 19:41:35 +01:00
committed by Ana Gelez
parent e6bdeb7c4b
commit f3c05dae62
17 changed files with 341 additions and 6 deletions
+14 -3
View File
@@ -484,8 +484,20 @@ pub fn validate_username(username: &str) -> Result<(), ValidationError> {
}
}
fn to_validation(_: Error) -> ValidationErrors {
fn to_validation(x: Error) -> ValidationErrors {
let mut errors = ValidationErrors::new();
if let Error::Blocklisted(show, msg) = x {
if show {
errors.add(
"email",
ValidationError {
code: Cow::from("blocklisted"),
message: Some(Cow::from(msg)),
params: HashMap::new(),
},
);
}
}
errors.add(
"",
ValidationError {
@@ -529,8 +541,7 @@ pub fn create(
"",
form.email.to_string(),
User::hash_pass(&form.password).map_err(to_validation)?,
)
.map_err(to_validation)?;
).map_err(to_validation)?;
Ok(Flash::success(
Redirect::to(uri!(super::session::new: m = _)),
i18n!(