diff --git a/src/js/_enqueues/admin/user-profile.js b/src/js/_enqueues/admin/user-profile.js
index df17620f48..d4aa676f29 100644
a
|
b
|
|
95 | 95 | var $generateButton, |
96 | 96 | $cancelButton; |
97 | 97 | |
98 | | $pass1Row = $( '.user-pass1-wrap, .user-pass-wrap' ); |
| 98 | $pass1Row = $( '.user-pass1-wrap, .user-pass-wrap, .reset-pass-submit' ); |
99 | 99 | |
100 | 100 | // Hide the confirm password field when JavaScript support is enabled. |
101 | 101 | $('.user-pass2-wrap').hide(); |
… |
… |
|
398 | 398 | } |
399 | 399 | } ); |
400 | 400 | |
| 401 | /** |
| 402 | * We need to call a generate password as soon as the Rest Password page is loaded |
| 403 | * to avoid double clicking on the button to retrieve the first generated password. |
| 404 | * Ticket: 39638 |
| 405 | */ |
| 406 | $( document ).ready( function() { |
| 407 | if ( $( '.reset-pass-submit' ).length ) { |
| 408 | $( '.reset-pass-submit button.wp-generate-pw' ).trigger( 'click' ); |
| 409 | } |
| 410 | }); |
| 411 | |
401 | 412 | })(jQuery); |
diff --git a/src/wp-admin/admin-ajax.php b/src/wp-admin/admin-ajax.php
index 144facf7fe..a539bf5863 100644
a
|
b
|
if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_po |
163 | 163 | add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 ); |
164 | 164 | } |
165 | 165 | |
| 166 | add_action( 'wp_ajax_nopriv_generate-password', 'wp_ajax_nopriv_generate_password' ); |
| 167 | |
166 | 168 | add_action( 'wp_ajax_nopriv_heartbeat', 'wp_ajax_nopriv_heartbeat', 1 ); |
167 | 169 | |
168 | 170 | $action = ( isset( $_REQUEST['action'] ) ) ? $_REQUEST['action'] : ''; |
diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php
index 6ff2d2d9fd..019ca53a65 100644
a
|
b
|
function wp_ajax_generate_password() { |
3976 | 3976 | wp_send_json_success( wp_generate_password( 24 ) ); |
3977 | 3977 | } |
3978 | 3978 | |
| 3979 | /** |
| 3980 | * Ajax handler for generating a password in |
| 3981 | * the no-privilege context. |
| 3982 | * |
| 3983 | * @since 5.7.0 |
| 3984 | */ |
| 3985 | function wp_ajax_nopriv_generate_password() { |
| 3986 | wp_send_json_success( wp_generate_password( 24 ) ); |
| 3987 | } |
| 3988 | |
3979 | 3989 | /** |
3980 | 3990 | * Ajax handler for saving the user's WordPress.org username. |
3981 | 3991 | * |
diff --git a/src/wp-login.php b/src/wp-login.php
index 915020f717..384474644e 100644
a
|
b
|
switch ( $action ) { |
996 | 996 | wp_enqueue_script( 'utils' ); |
997 | 997 | wp_enqueue_script( 'user-profile' ); |
998 | 998 | |
999 | | login_header( __( 'Reset Password' ), '<p class="message reset-pass">' . __( 'Enter your new password below.' ) . '</p>', $errors ); |
| 999 | login_header( __( 'Reset Password' ), '<p class="message reset-pass">' . __( 'Enter your new password below or generate one.' ) . '</p>', $errors ); |
1000 | 1000 | |
1001 | 1001 | ?> |
1002 | 1002 | <form name="resetpassform" id="resetpassform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" method="post" autocomplete="off"> |
… |
… |
switch ( $action ) { |
1042 | 1042 | |
1043 | 1043 | ?> |
1044 | 1044 | <input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" /> |
1045 | | <p class="submit"> |
1046 | | <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Reset Password' ); ?>" /> |
| 1045 | <p class="submit reset-pass-submit"> |
| 1046 | <button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="true">Generate Password</button> |
| 1047 | <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Save Password' ); ?>" /> |
1047 | 1048 | </p> |
1048 | 1049 | </form> |
1049 | 1050 | |