Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
afa6a18
Add a filter to adjust the providers available to each user
kasparsd Feb 14, 2025
eccac72
Use the new helper when getting providers for user
kasparsd Feb 14, 2025
6eed739
More references
kasparsd Feb 14, 2025
acba8c0
Better description to differentiate between available, enabled and su…
kasparsd Feb 14, 2025
d2c9ecc
Move the form into a helper for conditional rendering
kasparsd Feb 14, 2025
1aa2bfc
We have the user context so pass it along
kasparsd Feb 14, 2025
19938fb
The static hell is there
kasparsd Feb 14, 2025
927408c
Enabled providers returns just the keys so we need the supported ones…
kasparsd Feb 14, 2025
80d7f98
Add a unit test for the new filter
kasparsd Feb 14, 2025
f801c3a
Check for known things instead
kasparsd Feb 14, 2025
c06eff4
Pass the missing data
kasparsd Feb 14, 2025
a8cd102
Per linter
kasparsd Feb 14, 2025
6e4f0a6
Document the new filter
kasparsd Feb 14, 2025
e810859
Add the missing data
kasparsd Feb 14, 2025
63323e4
Move the fieldset logic to the caller where we know the state
kasparsd Feb 14, 2025
58e30e0
Add a helper to check if the method is supported for the user
kasparsd Feb 14, 2025
966285f
Don’t show the settings if the method is not supported for the user
kasparsd Feb 14, 2025
b7d593b
Per linter
kasparsd Feb 14, 2025
2bb236f
Reference the sub-class instead
kasparsd Feb 14, 2025
5422ba1
Keep together similar tests
kasparsd Feb 14, 2025
5f7783d
Test the new provider resolver
kasparsd Feb 14, 2025
aa8cfda
Test the filter impact to the new helper
kasparsd Feb 14, 2025
b2b605e
This is for the current session and not the user edited
kasparsd Feb 14, 2025
d506ba2
Describe the conditional better
kasparsd Mar 21, 2025
f39236f
Merge branch 'master' into filter-available-providers
kasparsd Mar 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Keep together similar tests
  • Loading branch information
kasparsd committed Feb 14, 2025
commit 5422ba14c81fc6738627090f228843f59858aa37
30 changes: 15 additions & 15 deletions tests/class-two-factor-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,21 @@ function( $providers, $user ) {
remove_all_filters( 'two_factor_providers_for_user' );
}

public function test_can_disable_default_providers() {
$this->assertContains( 'Two_Factor_Email', array_keys( Two_Factor_Core::get_providers() ), 'Email provider is enabled by default' );

add_filter(
'two_factor_providers',
function ( $providers ) {
return array_diff_key( $providers, array( 'Two_Factor_Email' => null ) );
}
);

$this->assertNotContains( 'Two_Factor_Email', array_keys( Two_Factor_Core::get_providers() ), 'Default provider can be disabled via a filter' );

remove_all_filters( 'two_factor_providers' );
}

/**
* Plugin uninstall removes all user meta.
*
Expand All @@ -1611,21 +1626,6 @@ public function test_uninstall_removes_user_meta() {
);
}

public function test_can_disable_default_providers() {
$this->assertContains( 'Two_Factor_Email', array_keys( Two_Factor_Core::get_providers() ), 'Email provider is enabled by default' );

add_filter(
'two_factor_providers',
function ( $providers ) {
return array_diff_key( $providers, array( 'Two_Factor_Email' => null ) );
}
);

$this->assertNotContains( 'Two_Factor_Email', array_keys( Two_Factor_Core::get_providers() ), 'Default provider can be disabled via a filter' );

remove_all_filters( 'two_factor_providers' );
}

/**
* Plugin uninstall removes all user meta even for disabled providers.
*
Expand Down