Repository navigation
Enable TOTP method when method is configured - #643
Conversation
…s one of the enabled options
| $user = self::factory()->user->create_and_get(); | ||
| $enabled_providers = Two_Factor_Core::get_enabled_providers_for_user( $user->ID ); | ||
| $this->assertEmpty( $enabled_providers ); | ||
| $this->assertEmpty( $enabled_providers, 'No providers are enabled by default' ); |
There was a problem hiding this comment.
These help us identify failing tests instead of just showing the test method name.
|
|
||
| $this->delete_user_totp_key( $user_id ); | ||
|
|
||
| if ( ! Two_Factor_Core::disable_provider_for_user( $user_id, 'Two_Factor_Totp' ) ) { |
There was a problem hiding this comment.
Deleting the TOTP key now also disables the method because it is unusable without the key.
| $enabled_providers[] = $new_provider; | ||
| $enabled = update_user_meta( $user_id, self::ENABLED_PROVIDERS_USER_META_KEY, $enabled_providers ); | ||
|
|
||
| // Primary provider must be enabled. |
There was a problem hiding this comment.
The primary provider is determined during get_primary_provider_for_user() so there is no need update it here. If no primary is configured, we always default to the first enabled.
|
|
||
| $error.find('p').text( errorMessage ); | ||
|
|
||
| $( '#enabled-Two_Factor_Totp' ).prop( 'checked', false ); |
There was a problem hiding this comment.
We now enable the TOTP method when the key has been registered by default.
| user_id: <?php echo wp_json_encode( $user->ID ); ?>, | ||
| key: key, | ||
| code: code, | ||
| enable_provider: true, |
There was a problem hiding this comment.
Instruct the validator to also enable the provider, if everything is a pass.
What?
Users expect a method to be enabled if they chose to configure it.
Why?
Fixes #556.
How?
Testing Instructions
Setup workflow:
Reset workflow:
Screenshots or screencast
totp-actions.mp4
Changelog Entry