Skip to content

Commit

Permalink
Make email_signups::create return ErrorPage on error
Browse files Browse the repository at this point in the history
  • Loading branch information
KitaitiMakoto committed Jan 12, 2022
1 parent 9bbfc71 commit 43b46a8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/routes/email_signups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn create(
conn: DbConn,
rockets: PlumeRocket,
_enabled: signups::Email,
) -> Result<RespondOrRedirect, Ructe> {
) -> Result<RespondOrRedirect, ErrorPage> {
let registration_open = Instance::get_local()
.map(|i| i.open_registrations)
.unwrap_or(true);
Expand All @@ -87,14 +87,15 @@ pub fn create(
}
let mut form = form.into_inner();
form.email = form.email.trim().to_owned();
form.validate().map_err(|err| {
render!(email_signups::new(
if let Err(err) = form.validate() {
return Ok(render!(email_signups::new(
&(&conn, &rockets).to_context(),
registration_open,
&form,
err
))
})?;
.into());
}
let res = EmailSignup::start(&conn, &form.email);
if let Some(err) = res.as_ref().err() {
return Ok(match err {
Expand Down

0 comments on commit 43b46a8

Please sign in to comment.