Skip to content

Commit bc8c02c

Browse files
committed
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>
1 parent 1003b8b commit bc8c02c

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

apps/settings/lib/SetupChecks/TwoFactorConfiguration.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
declare(strict_types=1);
44

55
/**
6-
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
6+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
77
* SPDX-License-Identifier: AGPL-3.0-or-later
88
*/
99
namespace OCA\Settings\SetupChecks;
1010

1111
use OC\Authentication\TwoFactorAuth\ProviderLoader;
12+
use OC\Authentication\TwoFactorAuth\ProviderSet;
1213
use OCP\IL10N;
1314
use OCP\SetupCheck\ISetupCheck;
1415
use OCP\SetupCheck\SetupResult;
@@ -21,7 +22,7 @@ public function __construct(
2122
}
2223

2324
public function getName(): string {
24-
return $this->l10n->t('Two factor configuration');
25+
return $this->l10n->t('Second factor configuration');
2526
}
2627

2728
public function getCategory(): string {
@@ -30,7 +31,9 @@ public function getCategory(): string {
3031

3132
public function run(): SetupResult {
3233
$providers = $this->providerLoader->getProviders();
33-
if (count($providers) === 0) {
34+
$providerSet = new ProviderSet($providers, false);
35+
$primaryProviders = $providerSet->getPrimaryProviders();
36+
if (count($primaryProviders) === 0) {
3437
return SetupResult::warning($this->l10n->t('This instance has no second factor provider available.'));
3538
} else {
3639
return SetupResult::success(
@@ -39,7 +42,7 @@ public function run(): SetupResult {
3942
[
4043
implode(', ', array_map(
4144
fn ($p) => '"' . $p->getDisplayName() . '"',
42-
$providers)
45+
$primaryProviders)
4346
)
4447
]
4548
)

0 commit comments

Comments
 (0)