diff --git a/src/sso.rs b/src/sso.rs index 935f2c8f..012beeac 100644 --- a/src/sso.rs +++ b/src/sso.rs @@ -462,14 +462,11 @@ pub async fn exchange_code(wrapped_code: &str, conn: &mut DbConn) -> ApiResult email.to_string(), - None => match user_info.email() { - None => err!("Neither id token nor userinfo contained an email"), - Some(email) => email.to_owned().to_string(), - }, - } - .to_lowercase(); + let email = match id_claims.email().or(user_info.email()) { + None => err!("Neither id token nor userinfo contained an email"), + Some(e) => e.to_string().to_lowercase(), + }; + let email_verified = id_claims.email_verified().or(user_info.email_verified()); let user_name = user_info.preferred_username().map(|un| un.to_string()); @@ -486,7 +483,7 @@ pub async fn exchange_code(wrapped_code: &str, conn: &mut DbConn) -> ApiResult ApiResult