Skip to content

Commit a49176e

Browse files
committed
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 git-svn-id: https://develop.svn.wordpress.org/trunk@60306 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6ac0efd commit a49176e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/js/_enqueues/admin/user-profile.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@
101101
return;
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' ) ) {
106108
$pass1.attr( 'type', 'text' );
@@ -110,6 +112,14 @@
110112
resetToggle( true );
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

115125
/**

0 commit comments

Comments
 (0)