diff --git a/functions.inc.php b/functions.inc.php index df9e397a..7cb017ca 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -1,21 +1,10 @@ checkUserTOTP(authentication_get_username(), $fTotp)) { - init_session(authentication_get_username(), true, true); + if (authentication_mfa_incomplete() && $totppf->checkUserTOTP(authentication_get_username(false), $fTotp)) { + init_session(authentication_get_username(false), true, true); // get superadmin status and store in session $h->init(authentication_get_username()); @@ -72,7 +53,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { header("Location: main.php"); exit(0); } else { - error_log("PostfixAdmin admin second factor login failed (username: " . authentication_get_username() . ", ip_address: {$_SERVER['REMOTE_ADDR']})"); + error_log("PostfixAdmin admin second factor login failed (username: " . authentication_get_username(false). ", ip_address: {$_SERVER['REMOTE_ADDR']})"); $error = $PALANG['pTotp_failed']; flash_error($PALANG['pTotp_failed']); } diff --git a/public/users/login-mfa.php b/public/users/login-mfa.php index 712a1e23..f2d5a25a 100644 --- a/public/users/login-mfa.php +++ b/public/users/login-mfa.php @@ -1,33 +1,13 @@ checkUserTOTP(authentication_get_username(), $fTotp)) { - init_session(authentication_get_username(), false, true); + if (authentication_mfa_incomplete() && $totppf->checkUserTOTP(authentication_get_username(false), $fTotp)) { + init_session(authentication_get_username(false), false, true); header("Location: main.php"); exit(0); } else { # $h->login failed - error_log("PostfixAdmin admin second factor login failed (username: " . authentication_get_username() . ", ip_address: {$_SERVER['REMOTE_ADDR']})"); + error_log("PostfixAdmin admin second factor login failed (username: " . authentication_get_username(false) . ", ip_address: {$_SERVER['REMOTE_ADDR']})"); flash_error($PALANG['pTotp_failed']); } } diff --git a/templates/login-mfa.tpl b/templates/login-mfa.tpl index aed38494..fd80a6e9 100644 --- a/templates/login-mfa.tpl +++ b/templates/login-mfa.tpl @@ -6,7 +6,7 @@ {CSRF_Token}