Skip to content

Commit 2eee45d

Browse files
committed
Merge remote-tracking branch 'origin/master' into profile-ux
# Conflicts: # class-two-factor-core.php
2 parents 90d5957 + 636dc0b commit 2eee45d

5 files changed

Lines changed: 40 additions & 33 deletions

File tree

class-two-factor-core.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,8 @@ public static function manage_users_custom_column( $output, $column_name, $user_
17881788
* @param WP_User $user WP_User object of the logged-in user.
17891789
*/
17901790
public static function user_two_factor_options( $user ) {
1791+
$notices = [];
1792+
17911793
wp_enqueue_style( 'user-edit-2fa', plugins_url( 'user-edit.css', __FILE__ ), array(), TWO_FACTOR_VERSION );
17921794

17931795
$enabled_providers = array_keys( self::get_available_providers_for_user( $user ) );
@@ -1802,17 +1804,17 @@ public static function user_two_factor_options( $user ) {
18021804
// This is specific to the current session, not the displayed user.
18031805
$show_2fa_options = self::current_user_can_update_two_factor_options() || true;
18041806

1805-
if ( ! $show_2fa_options && false ) {
1806-
$url = self::get_user_two_factor_revalidate_url();
1807-
$url = add_query_arg( 'redirect_to', urlencode( self::get_user_settings_page_url( $user->ID ) . '#two-factor-options' ), $url );
1807+
if ( ! $show_2fa_options ) {
1808+
$url = add_query_arg(
1809+
'redirect_to',
1810+
urlencode( self::get_user_settings_page_url( $user->ID ) . '#two-factor-options' ),
1811+
self::get_user_two_factor_revalidate_url()
1812+
);
18081813

1809-
printf(
1810-
'<div class="notice notice-warning inline"><p>%s</p></div>',
1811-
sprintf(
1812-
__( 'To update your Two-Factor options, you must first revalidate your session.', 'two-factor' ) .
1813-
'<br><a class="button" href="%s">' . __( 'Revalidate now', 'two-factor' ) . '</a>',
1814+
$notices['warning two-factor-warning-revalidate-session'] = sprintf(
1815+
esc_html__( 'To update your Two-Factor options, you must first revalidate your session.', 'two-factor' ) .
1816+
' <a class="button" href="%s">' . esc_html__( 'Revalidate now', 'two-factor' ) . '</a>',
18141817
esc_url( $url )
1815-
)
18161818
);
18171819
}
18181820

@@ -1821,22 +1823,20 @@ public static function user_two_factor_options( $user ) {
18211823
$show_2fa_options ? '' : 'disabled="disabled"'
18221824
);
18231825

1824-
$notices = [];
1825-
if ( empty( $enabled_providers ) ) {
1826-
$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' );
1827-
} elseif ( 1 === count( $enabled_providers ) ) {
1828-
$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' );
1826+
if ( 1 === count( $enabled_providers ) ) {
1827+
$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' );
18291828
}
1830-
18311829
?>
18321830
<h2><?php esc_html_e( 'Two-Factor Options', 'two-factor' ); ?></h2>
18331831

18341832
<?php foreach ( $notices as $notice_type => $notice ) : ?>
18351833
<div class="<?php echo esc_attr( $notice_type ? 'notice inline notice-' . $notice_type : '' ); ?>">
1836-
<p><?php echo esc_html( $notice ); ?></p>
1834+
<p><?php echo wp_kses_post( $notice ); ?></p>
18371835
</div>
18381836
<?php endforeach; ?>
1839-
1837+
<p>
1838+
<?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' ); ?>
1839+
</p>
18401840
<?php wp_nonce_field( 'user_two_factor_options', '_nonce_user_two_factor_options', false ); ?>
18411841
<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. */ ?>" />
18421842

composer.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

providers/class-two-factor-totp.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,13 @@ public function user_two_factor_options( $user ) {
356356

357357
<script>
358358
(function($){
359+
// Focus the auth code input when the checkbox is clicked.
360+
document.getElementById('enabled-Two_Factor_Totp').addEventListener('click', function(e) {
361+
if ( e.target.checked ) {
362+
document.getElementById('two-factor-totp-authcode').focus();
363+
}
364+
});
365+
359366
$('.totp-submit').click( function( e ) {
360367
e.preventDefault();
361368
var key = $('#two-factor-totp-key').val(),

readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Contributors: georgestephanis, valendesigns, stevenkword, extendwings, sgrant, aaroncampbell, johnbillion, stevegrunwell, netweb, kasparsd, alihusnainarshad, passoniate
33
Tags: 2fa, mfa, totp, authentication, security
44
Tested up to: 6.6
5-
Stable tag: 0.9.1
5+
Stable tag: 0.10.0
66
License: GPL-2.0-or-later
77
License URI: https://spdx.org/licenses/GPL-2.0-or-later.html
88

two-factor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Plugin Name: Two Factor
1212
* Plugin URI: https://wordpress.org/plugins/two-factor/
1313
* Description: Enable Two-Factor Authentication using time-based one-time passwords, Universal 2nd Factor (FIDO U2F, YubiKey), email, and backup verification codes.
14-
* Version: 0.9.1
14+
* Version: 0.10.0
1515
* Requires at least: 6.3
1616
* Requires PHP: 7.2
1717
* Author: WordPress.org Contributors
@@ -30,7 +30,7 @@
3030
/**
3131
* Version of the plugin.
3232
*/
33-
define( 'TWO_FACTOR_VERSION', '0.9.1' );
33+
define( 'TWO_FACTOR_VERSION', '0.10.0' );
3434

3535
/**
3636
* Include the base class here, so that other plugins can also extend it.

0 commit comments

Comments
 (0)