summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Reeder <vpzomtrrfrt@gmail.com>2020-10-08 17:08:50 -0600
committerColin Reeder <vpzomtrrfrt@gmail.com>2020-10-08 17:08:50 -0600
commit28f29d210fc90df8cd4b9879d0eb16bb69326f27 (patch)
treefe12f17527722f3153f2774c78fb3c32d09471bc
parent3d0f120023526c507e4d97f70fb633288401f260 (diff)
Ignore email address if empty (#103)
-rw-r--r--src/routes/mod.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/routes/mod.rs b/src/routes/mod.rs
index c651f43..5621345 100644
--- a/src/routes/mod.rs
+++ b/src/routes/mod.rs
@@ -1,5 +1,6 @@
use serde_derive::Deserialize;
use std::borrow::Cow;
+use std::collections::HashMap;
use std::sync::Arc;
use crate::components::{
@@ -1053,7 +1054,7 @@ async fn page_signup_inner(
ctx: Arc<crate::RouteContext>,
headers: &hyper::HeaderMap,
display_error: Option<String>,
- prev_values: Option<&serde_json::Value>,
+ prev_values: Option<&HashMap<Cow<'_, str>, serde_json::Value>>,
) -> Result<hyper::Response<hyper::Body>, crate::Error> {
let lang = crate::get_lang_for_headers(&headers);
let cookies = get_cookie_map_for_headers(&headers)?;
@@ -1111,8 +1112,11 @@ async fn handler_signup_submit(
let (req_parts, body) = req.into_parts();
let body = hyper::body::to_bytes(body).await?;
- let mut body: serde_json::Value = serde_urlencoded::from_bytes(&body)?;
- body["login"] = true.into();
+ let mut body: HashMap<Cow<'_, str>, serde_json::Value> = serde_urlencoded::from_bytes(&body)?;
+ body.insert("login".into(), true.into());
+ if body.get("email_address").and_then(|x| x.as_str()) == Some("") {
+ body.remove("email_address");
+ }
let api_res = res_to_error(
ctx.http_client