fix(settings): Only consider primary providers for 2FA setup check

In practice this filters out backup codes. Also fixed the english
 formulation and the copyright year.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2026-02-02 11:38:28 +01:00 committed by backportbot[bot]
parent e3cb237b04
commit 5b60fb23db

View file

@ -3,12 +3,13 @@
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Settings\SetupChecks;
use OC\Authentication\TwoFactorAuth\ProviderLoader;
use OC\Authentication\TwoFactorAuth\ProviderSet;
use OCP\IL10N;
use OCP\SetupCheck\ISetupCheck;
use OCP\SetupCheck\SetupResult;
@ -21,7 +22,7 @@ class TwoFactorConfiguration implements ISetupCheck {
}
public function getName(): string {
return $this->l10n->t('Two factor configuration');
return $this->l10n->t('Second factor configuration');
}
public function getCategory(): string {
@ -30,7 +31,9 @@ class TwoFactorConfiguration implements ISetupCheck {
public function run(): SetupResult {
$providers = $this->providerLoader->getProviders();
if (count($providers) === 0) {
$providerSet = new ProviderSet($providers, false);
$primaryProviders = $providerSet->getPrimaryProviders();
if (count($primaryProviders) === 0) {
return SetupResult::warning($this->l10n->t('This instance has no second factor provider available.'));
} else {
return SetupResult::success(
@ -39,7 +42,7 @@ class TwoFactorConfiguration implements ISetupCheck {
[
implode(', ', array_map(
fn ($p) => '"' . $p->getDisplayName() . '"',
$providers)
$primaryProviders)
)
]
)