Skip to content

Commit

Permalink
get_primary_provider_for_user() already ensures that primary is alway…
Browse files Browse the repository at this point in the history
…s one of the enabled options
  • Loading branch information
kasparsd committed Sep 19, 2024
1 parent a8a6c4a commit a5b2214
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions class-two-factor-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit a5b2214

Please sign in to comment.