From 5b60fb23db02812fb4101ef3cf5da2da872037b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 2 Feb 2026 11:38:28 +0100 Subject: [PATCH] fix(settings): Only consider primary providers for 2FA setup check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In practice this filters out backup codes. Also fixed the english formulation and the copyright year. Signed-off-by: Côme Chilliet --- .../lib/SetupChecks/TwoFactorConfiguration.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/settings/lib/SetupChecks/TwoFactorConfiguration.php b/apps/settings/lib/SetupChecks/TwoFactorConfiguration.php index f95c5358fdc..52e1966a7be 100644 --- a/apps/settings/lib/SetupChecks/TwoFactorConfiguration.php +++ b/apps/settings/lib/SetupChecks/TwoFactorConfiguration.php @@ -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) ) ] )