Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support filtering providers per user #648

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ocean90
Copy link
Member

@ocean90 ocean90 commented Nov 6, 2024

What?

Pass the current user to get_providers() and its filter.

Why?

Fixes #647.

How?

Update all get_providers() calls and the filter to support the new $user_id argument.

Testing Instructions

Use the following code to allow email and TOTP for the user with ID 1 and email for other users.

add_filter(
	'two_factor_providers',
	static function ( array $providers, ?int $user_id ): array {
		if ( 1 === $user_id ) {
			return array_intersect_key(
				$providers,
				[
					'Two_Factor_Email' => '',
					'Two_Factor_Totp'  => '',
				]
			);
		} else {
			return array_intersect_key(
				$providers,
				[
					'Two_Factor_Email' => '',
				]
			);
		}
	},
	10,
	2
);

Screenshots or screencast

Changelog Entry

Added - Allow to filter providers per user.

@ocean90
Copy link
Member Author

ocean90 commented Nov 6, 2024

Pending feedback regards the two_factor_providers filter: #637 (comment)

@jeffpaul jeffpaul added this to the 0.10.0 milestone Nov 12, 2024
@jeffpaul jeffpaul requested a review from kasparsd November 12, 2024 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to limit providers per user
2 participants