WordPress/two-factor

Provider: `Call to a member function get_key() on null`

StevenDufresne opened this issue · 1 comments

Describe the bug

In login_html we assume that a provider has been set when we call get_key(), however there are some code path's where a null provider is returned:

public static function login_html( $user, $login_nonce, $redirect_to, $error_msg = '', $provider = null, $action = 'validate_2fa' ) {

$provider_key = $provider->get_key();

I'm not sure how to bail out of this function gracefully.

Steps to Reproduce

It's a bit tricky to provide steps to reproduce but the scenario is that the user doesn't have a provider configured but the re-auth mechanism has requested the user re-auth.

It isn't a very common use case and somewhat external to this plugin, but handling the exception would probably make for a better api.

Screenshots, screen recording, code snippet

No response

Environment information

No response

Please confirm that you have searched existing issues in this repository.

Yes

Please confirm that you have tested with all plugins deactivated except Two-Factor.

Yes

There's already a related PR: #567.