Make WordPress Core

Opened 5 years ago

Last modified 7 days ago

#52256 reopened defect (bug)

Default hide password field.

Reported by: dilipbheda's profile dilipbheda Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.6
Component: Users Keywords: has-patch dev-feedback
Focuses: javascript, administration Cc:

Description

Generate password not working when the first click on generate password button.

Check different behavior in the below URLs

{siteurl}/wp-admin/user-new.php
{siteurl}/wp-admin/profile.php
{siteurl}/wp-admin/user-edit.php?user_id={user_id}

Check the video for a better understanding.
https://www.loom.com/share/2b91de25ab1447e3bb069738c0d318b8

Attachments (2)

52256.patch (792 bytes) - added by dilipbheda 5 years ago.
#52256.patch (740 bytes) - added by rehanali 4 years ago.
Added patch

Download all attachments as: .zip

Change History (7)

@dilipbheda
5 years ago

#1 @9primus
5 years ago

  • Component changed from Users to Administration
  • Resolution set to invalid
  • Status changed from new to closed
  • Version changed from trunk to 5.6

Hello ! I have solved this bug.
To fix this bug paste code below from codesandbox into \wp-admin\js\user-profile.min.js folder

https://codesandbox.io/s/romantic-driscoll-sws2u

I have added one condition to generatePassword function :

		} else if ( ! $pass1.val() || $passwordWrapper.hasClass( 'is-open' ) ) {
			// zxcvbn loaded before user entered password, or generating new password.
			let firstPassword = $pass1.data( 'pw' );
			if (firstPassword){
				$pass1.val(firstPassword);
				$pass1.data( 'pw',"" );
			} 

			$pass1.trigger( 'pwupdate' );
			showOrHideWeakPasswordCheckbox();

and edited ajax call in $generateButton.on( 'click',... function

			wp.ajax.post( 'generate-password' )
				.done( function( data ) {
					console.log(data);
					$pass1.val( data );
				} );

Your input tag for password should be like this (Path : \wp-admin\user-new.php) :

<?php
                                <?php $initial_password = wp_generate_password( 24 ); ?>
                                <span class="password-input-wrapper">
                                        <input type="password" 
                                        name="pass1" id="pass1" class="regular-text" autocomplete="off" 
                                        data-reveal="1" value="" data-pw="<?php echo esc_attr( $initial_password ); ?>"
                                        aria-describedby="pass-strength-result" />
                                </span>

If it helps you , please reaply)

#2 @dilipbheda
5 years ago

  • Keywords dev-feedback needs-testing added
  • Resolution invalid deleted
  • Status changed from closed to reopened

#3 @SergeyBiryukov
5 years ago

  • Component changed from Administration to Users

@rehanali
4 years ago

Added patch

#4 @joedolson
2 years ago

#56363 was marked as a duplicate.

#5 @ozgursar
7 days ago

  • Keywords needs-testing removed

Patch Testing Report

Patch Tested: https://core.trac.wordpress.org/attachment/ticket/52256/52256.patch

Environment

  • WordPress: 7.0-alpha-61215-src
  • PHP: 8.2.29
  • Server: nginx/1.29.4
  • Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 144.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-One 2.7
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.1

Steps taken

  1. Navigate to Users > Add User
  2. Click Generate Password button once
  3. Observe the password does not change
  4. Observe that subsequent clicks cause new passwords to be generated
  5. Apply patch
  6. Navigate to Users > Add User
  7. Password field is now not visible by default
  8. Each click to Generate Password button now generates a new password
  9. ✅ Patch is solving the problem.

Expected result

  • We are expecting Generate Password button to work from the initial click.

Screenshots/Screencast with results

Video before patch: https://files.catbox.moe/8imt1z.mp4

Video after patch: https://files.catbox.moe/0xiz93.mp4

Note: See TracTickets for help on using tickets.