[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [FIX] Refactor two-factor authentication handling in tiki-login.php
"SoftStart Code \(@softstartcode\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6962e4b3cd416_2c1808f86858a@gitlab-sidekiq-low-urgency-cpu-bound-v2-6fddf5c78d-lt47k.mail> |
SoftStart Code pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki Commits: 2c78b1c2 by Sandeep D at 2026-01-10T23:37:52+00:00 [FIX] Refactor two-factor authentication handling in tiki-login.php --- * [FIX] Refactor two-factor authentication handling in tiki-login.php --- * [FIX] Refactor two-factor authentication handling in tiki-login.php --- - Simplified the logic for determining if multi-factor authentication (MFA) is required. - Updated conditions to use null coalescing for preference checks. - Ensured that two-factor authentication is only processed when necessary See merge request tikiwiki/tiki!9263 (cherry picked from commit e85e6d6a1c45ae4f1778b2a915d84ea3066f6d8d) Co-authored-by: Sandeep D <sandeep.anandbhai-NHSG37FGo5wS/6/[email protected]> See merge request tikiwiki/tiki!9264 - - - - - 1 changed file: - tiki-login.php Changes: ===================================== tiki-login.php ===================================== @@ -318,12 +318,16 @@ if ( } } elseif ($isvalid) { try { - $twoFactorAuth = TwoFactorAuth::getTwoFactorAuth(); - $requireMfa = TwoFactorAuth::isMFARequired($requestedUser); - $twoFactorSecret = TwoFactorAuth::get2FactorSecret($requestedUser); + $requireMfa = false; + $twoFactorSecret = null; + + if (($prefs['twoFactorAuth'] ?? 'n') === 'y') { + $requireMfa = TwoFactorAuth::isMFARequired($requestedUser); + $twoFactorSecret = TwoFactorAuth::get2FactorSecret($requestedUser); + } if ( - $prefs['twoFactorAuth'] == 'y' + ($prefs['twoFactorAuth'] ?? 'n') === 'y' && isset($_REQUEST['login_mode']) && $_REQUEST['login_mode'] == 'popup' && $requireMfa @@ -336,7 +340,8 @@ if ( exit; } - if ($prefs['twoFactorAuth'] == 'y' && $requireMfa && ! empty($twoFactorSecret)) { + if (($prefs['twoFactorAuth'] ?? 'n') === 'y' && $requireMfa && ! empty($twoFactorSecret)) { + $twoFactorAuth = TwoFactorAuth::getTwoFactorAuth(); $is2FaPass = $twoFactorAuth->validateCode($requestedUser, $_REQUEST['twoFactorAuthCode']); if (! $is2FaPass) { $error = TWO_FA_INCORRECT; @@ -352,7 +357,7 @@ if ( } if ($isvalid) { - if ($requireMfa && $prefs['twoFactorAuth'] === 'y') { + if ($requireMfa && ($prefs['twoFactorAuth'] ?? 'n') === 'y') { $userlib->updateLastMFADate($requestedUser); } $isdue = $userlib->is_due($requestedUser, $method); View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2c78b1c24140b554ab5d58ea13632e1e08913d55 -- View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2c78b1c24140b554ab5d58ea13632e1e08913d55 You're receiving this email because of your account on gitlab.com. _______________________________________________ TikiWiki-cvs mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs