Explorar o código

Fix wrong display of MFA email.

There was some wrong logic regarding the display of which email is
configured to be used for the email MFA. This is now fixed.

Resolves #1878
BlackDex %!s(int64=4) %!d(string=hai) anos
pai
achega
881d1f4334
Modificáronse 1 ficheiros con 7 adicións e 5 borrados
  1. 7 5
      src/api/core/two_factor/email.rs

+ 7 - 5
src/api/core/two_factor/email.rs

@@ -80,14 +80,16 @@ fn get_email(data: JsonUpcase<PasswordData>, headers: Headers, conn: DbConn) ->
         err!("Invalid password");
     }
 
-    let type_ = TwoFactorType::Email as i32;
-    let enabled = match TwoFactor::find_by_user_and_type(&user.uuid, type_, &conn) {
-        Some(x) => x.enabled,
-        _ => false,
+    let (enabled, mfa_email) = match TwoFactor::find_by_user_and_type(&user.uuid, TwoFactorType::Email as i32, &conn) {
+        Some(x) => {
+            let twofactor_data = EmailTokenData::from_json(&x.data)?;
+            (true, json!(twofactor_data.email))
+        }
+        _ => (false, json!(null)),
     };
 
     Ok(Json(json!({
-        "Email": user.email,
+        "Email": mfa_email,
         "Enabled": enabled,
         "Object": "twoFactorEmail"
     })))