oauth2: replace unwrap() and is_none() with "if let"

This commit is contained in:
Alexander Krotov
2020-01-11 15:42:01 +03:00
committed by holger krekel
parent 9a43d26c60
commit fde8fb960b

View File

@@ -312,13 +312,12 @@ impl Oauth2 {
} }
if let Ok(response) = parsed { if let Ok(response) = parsed {
// serde_json::Value.as_str() removes the quotes of json-strings // serde_json::Value.as_str() removes the quotes of json-strings
let addr = response.get("email"); if let Some(addr) = response.get("email") {
if addr.is_none() { Some(addr.to_string())
} else {
warn!(context, "E-mail missing in userinfo."); warn!(context, "E-mail missing in userinfo.");
return None; None
} }
let addr = addr.unwrap().as_str();
addr.map(|addr| addr.to_string())
} else { } else {
warn!(context, "Failed to parse userinfo."); warn!(context, "Failed to parse userinfo.");
None None