-
Notifications
You must be signed in to change notification settings - Fork 3.3k
The WordPress core password reset needs to pre-populate the username to meet WCAG 2.2 #8122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @pratik-londhe4. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
I've tested the above patch locally, and it seems to be working as expected. The username is pre-populated when the user resets their password and navigates to the login page afterward. |
|
Please see my note on the original PR implimenting this change, it duplicates the issues discussed there. |
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Reuses an existing parameter, preventing potential interference with extensions.
|
I've updated the PR to address feedback by @westonruter and @peterwilsoncc; could use a review. |
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
This isn't needed; the value is already available after submitting the form.
|
@joedolson In reviewing this, I noticed that there is an existing With that change, the resulting code is much simpler: diff --git a/src/wp-login.php b/src/wp-login.php
index c9db31826b..944aefa184 100644
--- a/src/wp-login.php
+++ b/src/wp-login.php
@@ -1000,7 +1000,6 @@ switch ( $action ) {
if ( ( ! $errors->has_errors() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) {
reset_password( $user, $_POST['pass1'] );
- setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
login_header(
__( 'Password Reset' ),
wp_get_admin_notice(
@@ -1507,6 +1506,10 @@ switch ( $action ) {
}
wp_enqueue_script( 'user-profile' );
+ $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
+ if ( ! $user_login && isset( $_COOKIE[ $rp_cookie ] ) && is_string( $_COOKIE[ $rp_cookie ] ) ) {
+ $user_login = sanitize_user( strtok( wp_unslash( $_COOKIE[ $rp_cookie ] ), ':' ) );
+ }
?>
<form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post"> |
|
@westonruter Yes, I agree - that would greatly simplify things. It seems to me that we could also still delete the cookie; we just have to do it after recovering the value. I don't think there's any real need for that cookie to persist beyond that point to meet the requirements. What do you think? |
Great. I merged those commits into this branch.
That sounds fine to me, although I wasn't sure where that deletion should happen. Maybe here? wordpress-develop/src/wp-login.php Lines 1484 to 1487 in 57dbb4c
In any case, the cookie is already set to expire when the session ends, so it doesn't seem critical to explicitly delete. But I am not a cookie lawyer 😃 |
Co-authored-by: Joe Dolson <design@joedolson.com>
|
@joedolson I implemented this in b8b2f72. It seems to work. It means the cookie won't be cleared upon a visiting the |
Co-authored-by: Weston Ruter <westonruter@gmail.com>
|
Yeah, I'm not a cookie lawyer, either. I just play one on tv. My only feeling about that is that if somebody previous thought it was worthwhile to delete that cookie, and we don't need to keep it longer to fix this issue, we might as well delete it. I'm going to do a final test of this, but I think this is pretty much ready. Really happy to have been able to significantly simplify the scope of changes. |
joedolson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Trac ticket: https://core.trac.wordpress.org/ticket/60726
This PR prepopulate the username into the login form after the password reset using the existing query parameter.