Skip to content

Commit 7ca7259

Browse files
committed
Login and Registration: Populate username after password reset.
Accessibility: to meet WCAG 2.2/3.3.7: Redundant entry, the username should be auto-populated when a user performs a password reset. There is an existing cookie set that contains this information, but was deleted before displaying the login form. Move cookie deletion to occur after displaying login form and use to set `$user_login`. Props estelaris, alh0319, sabernhardt, oglekler, peterwilsoncc, rcreators, rishavdutta, chaion07, stoyangeorgiev, rinkalpagdar, pratiklondhe, lukasfritzedev, ferdoused, audrasjb, westonruter, joedolson. Fixes #60726. Built from https://develop.svn.wordpress.org/trunk@61610 git-svn-id: http://core.svn.wordpress.org/trunk@60921 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent 60e5bce commit 7ca7259

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '7.0-alpha-61609';
19+
$wp_version = '7.0-alpha-61610';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

wp-login.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,6 @@ function wp_login_viewport_meta() {
10001000

10011001
if ( ( ! $errors->has_errors() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) {
10021002
reset_password( $user, $_POST['pass1'] );
1003-
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
10041003
login_header(
10051004
__( 'Password Reset' ),
10061005
wp_get_admin_notice(
@@ -1487,6 +1486,14 @@ function wp_login_viewport_meta() {
14871486
wp_clear_auth_cookie();
14881487
}
14891488

1489+
// Obtain user from password reset cookie flow before clearing the cookie.
1490+
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
1491+
if ( isset( $_COOKIE[ $rp_cookie ] ) && is_string( $_COOKIE[ $rp_cookie ] ) ) {
1492+
$user_login = sanitize_user( strtok( wp_unslash( $_COOKIE[ $rp_cookie ] ), ':' ) );
1493+
list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) );
1494+
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
1495+
}
1496+
14901497
login_header( __( 'Log In' ), '', $errors );
14911498

14921499
if ( isset( $_POST['log'] ) ) {

0 commit comments

Comments
 (0)