Make WordPress Core

Changeset 50153


Ignore:
Timestamp:
02/02/2021 06:11:26 PM (14 months ago)
Author:
SergeyBiryukov
Message:

Login and Registration: Improve the UX of the Reset Password screen.

Previously, it was unclear that the displayed password is only being suggested and should be saved by clicking the Reset Password button.

This adds separate Generate Password and Save Password buttons, for clarity.

Props xkon, estelaris, jaymanpandya, hedgefield, audrasjb, erichmond, magicroundabout, lukecavanagh, knutsp, tinodidriksen, nico_martin, markhowellsmead, kara.mcnair, e_baker, pixelverbieger, souri_wpaustria, megabyterose, poena, whyisjake.
Fixes #39638.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/user-profile.js

    r50129 r50153  
    158158            $cancelButton;
    159159
    160         $pass1Row = $( '.user-pass1-wrap, .user-pass-wrap' );
     160        $pass1Row = $( '.user-pass1-wrap, .user-pass-wrap, .reset-pass-submit' );
    161161
    162162        // Hide the confirm password field when JavaScript support is enabled.
     
    462462    } );
    463463
     464    /*
     465     * We need to generate a password as soon as the Reset Password page is loaded,
     466     * to avoid double clicking the button to retrieve the first generated password.
     467     * See ticket #39638.
     468     */
     469    $( document ).ready( function() {
     470        if ( $( '.reset-pass-submit' ).length ) {
     471            $( '.reset-pass-submit button.wp-generate-pw' ).trigger( 'click' );
     472        }
     473    });
     474
    464475})(jQuery);
  • trunk/src/wp-admin/admin-ajax.php

    r50129 r50153  
    165165}
    166166
     167add_action( 'wp_ajax_nopriv_generate-password', 'wp_ajax_nopriv_generate_password' );
     168
    167169add_action( 'wp_ajax_nopriv_heartbeat', 'wp_ajax_nopriv_heartbeat', 1 );
    168170
  • trunk/src/wp-admin/includes/ajax-actions.php

    r50146 r50153  
    1313
    1414/**
    15  * Ajax handler for the Heartbeat API in
    16  * the no-privilege context.
     15 * Ajax handler for the Heartbeat API in the no-privilege context.
    1716 *
    1817 * Runs when the user is not logged in.
     
    39783977
    39793978/**
     3979 * Ajax handler for generating a password in the no-privilege context.
     3980 *
     3981 * @since 5.7.0
     3982 */
     3983function wp_ajax_nopriv_generate_password() {
     3984    wp_send_json_success( wp_generate_password( 24 ) );
     3985}
     3986
     3987/**
    39803988 * Ajax handler for saving the user's WordPress.org username.
    39813989 *
  • trunk/src/wp-login.php

    r50129 r50153  
    853853        wp_enqueue_script( 'user-profile' );
    854854
    855         login_header( __( 'Reset Password' ), '<p class="message reset-pass">' . __( 'Enter your new password below.' ) . '</p>', $errors );
     855        login_header( __( 'Reset Password' ), '<p class="message reset-pass">' . __( 'Enter your new password below or generate one.' ) . '</p>', $errors );
    856856
    857857        ?>
     
    899899            ?>
    900900            <input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" />
    901             <p class="submit">
    902                 <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Reset Password' ); ?>" />
     901            <p class="submit reset-pass-submit">
     902                <button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="true"><?php _e( 'Generate Password' ); ?></button>
     903                <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Save Password' ); ?>" />
    903904            </p>
    904905        </form>
Note: See TracChangeset for help on using the changeset viewer.