Use into() instead of explicitly wrapping return values
This commit is contained in:
parent
6498dbfbb7
commit
7c82b08615
@ -70,16 +70,15 @@ pub fn create(
|
|||||||
conn: DbConn,
|
conn: DbConn,
|
||||||
rockets: PlumeRocket,
|
rockets: PlumeRocket,
|
||||||
) -> Result<RespondOrRedirect, Ructe> {
|
) -> Result<RespondOrRedirect, Ructe> {
|
||||||
use RespondOrRedirect::{FlashRedirect, Response};
|
|
||||||
|
|
||||||
if !matches!(CONFIG.signup, SignupStrategy::Email) {
|
if !matches!(CONFIG.signup, SignupStrategy::Email) {
|
||||||
return Ok(FlashRedirect(Flash::error(
|
return Ok(Flash::error(
|
||||||
Redirect::to(uri!(super::user::new)),
|
Redirect::to(uri!(super::user::new)),
|
||||||
i18n!(
|
i18n!(
|
||||||
rockets.intl.catalog,
|
rockets.intl.catalog,
|
||||||
"Email registrations are not enabled. Please restart."
|
"Email registrations are not enabled. Please restart."
|
||||||
),
|
),
|
||||||
)));
|
)
|
||||||
|
.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
let registration_open = !Instance::get_local()
|
let registration_open = !Instance::get_local()
|
||||||
@ -87,13 +86,14 @@ pub fn create(
|
|||||||
.unwrap_or(true);
|
.unwrap_or(true);
|
||||||
|
|
||||||
if registration_open {
|
if registration_open {
|
||||||
return Ok(FlashRedirect(Flash::error(
|
return Ok(Flash::error(
|
||||||
Redirect::to(uri!(super::user::new)),
|
Redirect::to(uri!(super::user::new)),
|
||||||
i18n!(
|
i18n!(
|
||||||
rockets.intl.catalog,
|
rockets.intl.catalog,
|
||||||
"Registrations are closed on this instance."
|
"Registrations are closed on this instance."
|
||||||
),
|
),
|
||||||
))); // Actually, it is an error
|
)
|
||||||
|
.into()); // Actually, it is an error
|
||||||
}
|
}
|
||||||
let mut form = form.into_inner();
|
let mut form = form.into_inner();
|
||||||
form.email = form.email.trim().to_owned();
|
form.email = form.email.trim().to_owned();
|
||||||
@ -111,14 +111,10 @@ pub fn create(
|
|||||||
Error::UserAlreadyExists => {
|
Error::UserAlreadyExists => {
|
||||||
// TODO: Notify to admin (and the user?)
|
// TODO: Notify to admin (and the user?)
|
||||||
warn!("Registration attempted for existing user: {}. Registraion halted and email sending skipped.", &form.email);
|
warn!("Registration attempted for existing user: {}. Registraion halted and email sending skipped.", &form.email);
|
||||||
Response(render!(email_signups::create(
|
render!(email_signups::create(&(&conn, &rockets).to_context())).into()
|
||||||
&(&conn, &rockets).to_context()
|
|
||||||
)))
|
|
||||||
}
|
}
|
||||||
Error::NotFound => {
|
Error::NotFound => render!(errors::not_found(&(&conn, &rockets).to_context())).into(),
|
||||||
Response(render!(errors::not_found(&(&conn, &rockets).to_context())))
|
_ => render!(errors::not_found(&(&conn, &rockets).to_context())).into(), // FIXME
|
||||||
}
|
|
||||||
_ => Response(render!(errors::not_found(&(&conn, &rockets).to_context()))), // FIXME
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let token = res.unwrap();
|
let token = res.unwrap();
|
||||||
@ -138,9 +134,7 @@ pub fn create(
|
|||||||
mailer.send(message.into()).ok(); // TODO: Render error page
|
mailer.send(message.into()).ok(); // TODO: Render error page
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Response(render!(email_signups::create(
|
Ok(render!(email_signups::create(&(&conn, &rockets).to_context())).into())
|
||||||
&(&conn, &rockets).to_context()
|
|
||||||
))))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/email_signups/new")]
|
#[get("/email_signups/new")]
|
||||||
|
Loading…
Reference in New Issue
Block a user