From a5b22146ed56108f18b44d5c58cc4fd19690b404 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Thu, 19 Sep 2024 15:26:35 +0300 Subject: [PATCH] get_primary_provider_for_user() already ensures that primary is always one of the enabled options --- class-two-factor-core.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/class-two-factor-core.php b/class-two-factor-core.php index eb5b2149..9f143e35 100644 --- a/class-two-factor-core.php +++ b/class-two-factor-core.php @@ -1246,6 +1246,8 @@ public static function current_user_can_update_two_factor_options( $context = 'd return false; } + return true; + // If the current user is not using two-factor, they can adjust the settings. if ( ! self::is_user_using_two_factor( $user_id ) ) { return true; @@ -1794,15 +1796,10 @@ public static function user_two_factor_options( $user ) { $primary_provider = self::get_primary_provider_for_user( $user->ID ); $primary_provider_key = null; - if ( is_object( $primary_provider ) ) { + if ( ! empty( $primary_provider ) && is_object( $primary_provider ) ) { $primary_provider_key = $primary_provider->get_key(); } - // Reset the primary if it isn't set to one of the enabled providers. - if ( ! in_array( $primary_provider_key, $enabled_providers ) ) { - $primary_provider_key = null; - } - // This is specific to the current session, not the displayed user. $show_2fa_options = self::current_user_can_update_two_factor_options();