diff --git a/administrator/components/com_users/config.xml b/administrator/components/com_users/config.xml index 4238d255eebad..f02345cff79c4 100644 --- a/administrator/components/com_users/config.xml +++ b/administrator/components/com_users/config.xml @@ -123,6 +123,16 @@ + +
getIdentity()->id; + $user = $this->getIdentity(); - if (!$userId) + if (!$user->id) { return false; } @@ -1188,7 +1188,22 @@ protected function isTwoFactorAuthenticationRequired(): bool return false; } - $enforce2faOptions = ComponentHelper::getComponent('com_users')->getParams()->get('enforce_2fa_options', 0); + $comUsersParams = ComponentHelper::getComponent('com_users')->getParams(); + + // Check if 2fa is enforced for the logged in user. + $forced2faGroups = (array) $comUsersParams->get('enforce_2fa_usergroups', []); + + if (!empty($forced2faGroups)) + { + $userGroups = (array) $user->get('groups', []); + + if (!array_intersect($forced2faGroups, $userGroups)) + { + return false; + } + } + + $enforce2faOptions = $comUsersParams->get('enforce_2fa_options', 0); if ($enforce2faOptions == 0 || !$enforce2faOptions) {