mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
make oauth2.get_addr work
oauth2.get_addr is used for gmail-oauth2 to retrieve the address really authorized in the oauth2 process.
This commit is contained in:
@@ -112,6 +112,7 @@ pub fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context) {
|
|||||||
dc_get_oauth2_addr(context, ¶m.addr, ¶m.mail_pw)
|
dc_get_oauth2_addr(context, ¶m.addr, ¶m.mail_pw)
|
||||||
.and_then(|e| e.parse().ok())
|
.and_then(|e| e.parse().ok())
|
||||||
{
|
{
|
||||||
|
info!(context, "Authorized address is {}", oauth2_addr);
|
||||||
param.addr = oauth2_addr;
|
param.addr = oauth2_addr;
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ impl Oauth2 {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let parsed: reqwest::Result<HashMap<String, String>> = response.json();
|
let parsed: reqwest::Result<HashMap<String, serde_json::Value>> = response.json();
|
||||||
if parsed.is_err() {
|
if parsed.is_err() {
|
||||||
warn!(
|
warn!(
|
||||||
context,
|
context,
|
||||||
@@ -306,11 +306,13 @@ impl Oauth2 {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
if let Ok(response) = parsed {
|
if let Ok(response) = parsed {
|
||||||
|
// serde_json::Value.as_str() removes the quotes of json-strings
|
||||||
let addr = response.get("email");
|
let addr = response.get("email");
|
||||||
if addr.is_none() {
|
if addr.is_none() {
|
||||||
warn!(context, "E-mail missing in userinfo.");
|
warn!(context, "E-mail missing in userinfo.");
|
||||||
|
return None;
|
||||||
}
|
}
|
||||||
|
let addr = addr.unwrap().as_str();
|
||||||
addr.map(|addr| addr.to_string())
|
addr.map(|addr| addr.to_string())
|
||||||
} else {
|
} else {
|
||||||
warn!(context, "Failed to parse userinfo.");
|
warn!(context, "Failed to parse userinfo.");
|
||||||
|
|||||||
Reference in New Issue
Block a user