WordPress.org

Make WordPress Core

Opened 10 months ago

Last modified 10 months ago

#52256 reopened defect (bug)

Default hide password field.

Reported by: dilipbheda Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.6
Component: Users Keywords: has-patch dev-feedback needs-testing
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 (1)

52256.patch (792 bytes) - added by dilipbheda 10 months ago.

Download all attachments as: .zip

Change History (4)

@dilipbheda
10 months ago

#1 @9primus
10 months 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
10 months ago

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

#3 @SergeyBiryukov
10 months ago

  • Component changed from Administration to Users
Note: See TracTickets for help on using tickets.