-
Notifications
You must be signed in to change notification settings - Fork 156
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
Encourage setting up a second recovery method #642
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1788,6 +1788,8 @@ public static function manage_users_custom_column( $output, $column_name, $user_ | |
* @param WP_User $user WP_User object of the logged-in user. | ||
*/ | ||
public static function user_two_factor_options( $user ) { | ||
$notices = []; | ||
|
||
wp_enqueue_style( 'user-edit-2fa', plugins_url( 'user-edit.css', __FILE__ ), array(), TWO_FACTOR_VERSION ); | ||
|
||
$enabled_providers = array_keys( self::get_available_providers_for_user( $user ) ); | ||
|
@@ -1803,16 +1805,16 @@ public static function user_two_factor_options( $user ) { | |
$show_2fa_options = self::current_user_can_update_two_factor_options(); | ||
|
||
if ( ! $show_2fa_options ) { | ||
$url = self::get_user_two_factor_revalidate_url(); | ||
$url = add_query_arg( 'redirect_to', urlencode( self::get_user_settings_page_url( $user->ID ) . '#two-factor-options' ), $url ); | ||
$url = add_query_arg( | ||
'redirect_to', | ||
urlencode( self::get_user_settings_page_url( $user->ID ) . '#two-factor-options' ), | ||
self::get_user_two_factor_revalidate_url() | ||
); | ||
|
||
printf( | ||
'<div class="notice notice-warning inline"><p>%s</p></div>', | ||
sprintf( | ||
__( 'To update your Two-Factor options, you must first revalidate your session.', 'two-factor' ) . | ||
'<br><a class="button" href="%s">' . __( 'Revalidate now', 'two-factor' ) . '</a>', | ||
$notices['warning two-factor-warning-revalidate-session'] = sprintf( | ||
esc_html__( 'To update your Two-Factor options, you must first revalidate your session.', 'two-factor' ) . | ||
' <a class="button" href="%s">' . esc_html__( 'Revalidate now', 'two-factor' ) . '</a>', | ||
esc_url( $url ) | ||
) | ||
); | ||
} | ||
|
||
|
@@ -1821,9 +1823,20 @@ public static function user_two_factor_options( $user ) { | |
$show_2fa_options ? '' : 'disabled="disabled"' | ||
); | ||
|
||
wp_nonce_field( 'user_two_factor_options', '_nonce_user_two_factor_options', false ); | ||
if ( 1 === count( $enabled_providers ) ) { | ||
$notices['warning two-factor-warning-suggest-backup'] = esc_html__( 'To prevent being locked out of your account, consider enabling a backup method like Recovery Codes in case you lose access to your primary authentication method.', 'two-factor' ); | ||
} | ||
?> | ||
<h2><?php esc_html_e( 'Two-Factor Options', 'two-factor' ); ?></h2> | ||
<?php foreach ( $notices as $notice_type => $notice ) : ?> | ||
<div class="<?php echo esc_attr( $notice_type ? 'notice inline notice-' . $notice_type : '' ); ?>"> | ||
<p><?php echo wp_kses_post( $notice ); ?></p> | ||
</div> | ||
<?php endforeach; ?> | ||
<p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are now permanent instructions suggest the best-practice setup. |
||
<?php esc_html_e( 'Configure a primary two-factor method along with a backup method, such as Recovery Codes, to avoid being locked out if you lose access to your primary method.', 'two-factor' ); ?> | ||
</p> | ||
<?php wp_nonce_field( 'user_two_factor_options', '_nonce_user_two_factor_options', false ); ?> | ||
<input type="hidden" name="<?php echo esc_attr( self::ENABLED_PROVIDERS_USER_META_KEY ); ?>[]" value="<?php /* Dummy input so $_POST value is passed when no providers are enabled. */ ?>" /> | ||
<table class="wp-list-table widefat fixed striped table-view-list two-factor-methods-table"> | ||
<thead> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the hidden meaning of the first key string being the class suffix for
notice-*
but that's how we can allow for multiple notices of the same type without introducing some kind of an abstraction.