diff --git a/class-two-factor-core.php b/class-two-factor-core.php index a1450cc6..0b69ea04 100644 --- a/class-two-factor-core.php +++ b/class-two-factor-core.php @@ -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 ) ); @@ -1802,17 +1804,17 @@ public static function user_two_factor_options( $user ) { // This is specific to the current session, not the displayed user. $show_2fa_options = self::current_user_can_update_two_factor_options() || true; - if ( ! $show_2fa_options && false ) { - $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 ); + if ( ! $show_2fa_options ) { + $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( - '

%s

', - sprintf( - __( 'To update your Two-Factor options, you must first revalidate your session.', 'two-factor' ) . - '
' . __( 'Revalidate now', 'two-factor' ) . '', + $notices['warning two-factor-warning-revalidate-session'] = sprintf( + esc_html__( 'To update your Two-Factor options, you must first revalidate your session.', 'two-factor' ) . + ' ' . esc_html__( 'Revalidate now', 'two-factor' ) . '', esc_url( $url ) - ) ); } @@ -1821,22 +1823,20 @@ public static function user_two_factor_options( $user ) { $show_2fa_options ? '' : 'disabled="disabled"' ); - $notices = []; - if ( empty( $enabled_providers ) ) { - $notices[] = __( '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' ); - } elseif ( 1 === count( $enabled_providers ) ) { - $notices['warning'] = __( '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' ); + 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' ); } - ?>

$notice ) : ?>
-

+

- +

+ +

diff --git a/composer.lock b/composer.lock index f1ecd991..94142ae5 100644 --- a/composer.lock +++ b/composer.lock @@ -4173,20 +4173,20 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "77fa7995ac1b21ab60769b7323d600a991a90433" + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433", - "reference": "77fa7995ac1b21ab60769b7323d600a991a90433", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "type": "library", "extra": { @@ -4233,7 +4233,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" }, "funding": [ { @@ -4249,7 +4249,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-php81", @@ -4329,16 +4329,16 @@ }, { "name": "symfony/process", - "version": "v5.4.40", + "version": "v5.4.46", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "deedcb3bb4669cae2148bc920eafd2b16dc7c046" + "reference": "01906871cb9b5e3cf872863b91aba4ec9767daf4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/deedcb3bb4669cae2148bc920eafd2b16dc7c046", - "reference": "deedcb3bb4669cae2148bc920eafd2b16dc7c046", + "url": "https://api.github.com/repos/symfony/process/zipball/01906871cb9b5e3cf872863b91aba4ec9767daf4", + "reference": "01906871cb9b5e3cf872863b91aba4ec9767daf4", "shasum": "" }, "require": { @@ -4371,7 +4371,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.4.40" + "source": "https://github.com/symfony/process/tree/v5.4.46" }, "funding": [ { @@ -4387,7 +4387,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:33:22+00:00" + "time": "2024-11-06T09:18:28+00:00" }, { "name": "symfony/service-contracts", diff --git a/providers/class-two-factor-totp.php b/providers/class-two-factor-totp.php index 7bafe1a1..003a9774 100644 --- a/providers/class-two-factor-totp.php +++ b/providers/class-two-factor-totp.php @@ -356,6 +356,13 @@ public function user_two_factor_options( $user ) {