[TikiWiki-commits] [Git][tikiwiki/tiki][master] [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 | <694a863ac4e58_2a17fd6870577@gitlab-sidekiq-low-urgency-cpu-bound-v2-587dc6b794-vvm4b.mail> |
SoftStart Code pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
e85e6d6a by Sandeep D at 2025-12-23T11:59:26+00:00
[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
- - - - -
1 changed file:
- tiki-login.php
Changes:
=====================================
tiki-login.php
=====================================
@@ -322,12 +322,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
@@ -340,7 +344,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;
@@ -356,7 +361,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/e85e6d6a1c45ae4f1778b2a915d84ea3066f6d8d
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/e85e6d6a1c45ae4f1778b2a915d84ea3066f6d8d
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