Make WordPress Core

Changeset 60306


Ignore:
Timestamp:
06/13/2025 10:35:04 AM (4 weeks ago)
Author:
johnbillion
Message:

Login and Registration: Ensure a revealed password is reverted to the password input type upon form submission.

This means if a password has been toggled to visible by the user, or is visible by default, it gets reverted to the password type to prevent browsers from remembering it as a previously-provided value and potentially displaying it as an autofill option on non-password inputs.

Props jamieburchell, sukhendu2002, vgnavada

Fixes #62147

File:
1 edited

Legend:

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

    r60268 r60306  
    102102        }
    103103        $toggleButton = $pass1Row.find('.wp-hide-pw');
     104
     105        // Toggle between showing and hiding the password.
    104106        $toggleButton.show().on( 'click', function () {
    105107            if ( 'password' === $pass1.attr( 'type' ) ) {
     
    111113            }
    112114        });
     115
     116        // Ensure the password input type is set to password when the form is submitted.
     117        $pass1Row.closest( 'form' ).on( 'submit', function() {
     118            if ( $pass1.attr( 'type' ) === 'text' ) {
     119                $pass1.attr( 'type', 'password' );
     120                resetToggle( true );
     121            }
     122        } );
    113123    }
    114124
Note: See TracChangeset for help on using the changeset viewer.