Skip to content
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

Fixed : A password change should not destroy a user's session data #6950

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix the token re-use.
johnbillion committed Jan 16, 2025

Unverified

This user has not yet uploaded their public signing key.
commit db653e9102a19be8e7b3ae3e463d193843e74b66
11 changes: 7 additions & 4 deletions src/wp-includes/user.php
Original file line number Diff line number Diff line change
@@ -2780,8 +2780,6 @@ function wp_update_user( $userdata ) {
$current_user = wp_get_current_user();
if ( $current_user->ID === $user_id ) {
if ( isset( $plaintext_pass ) ) {
wp_clear_auth_cookie();

/*
* Here we calculate the expiration length of the current auth cookie and compare it to the default expiration.
* If it's greater than this, then we know the user checked 'Remember Me' when they logged in.
@@ -2790,15 +2788,20 @@ function wp_update_user( $userdata ) {
/** This filter is documented in wp-includes/pluggable.php */
$default_cookie_life = apply_filters( 'auth_cookie_expiration', ( 2 * DAY_IN_SECONDS ), $user_id, false );

wp_clear_auth_cookie();

$remember = false;
$token = '';

if ( false !== $logged_in_cookie ) {
$token = $logged_in_cookie['token'];
}

if ( false !== $logged_in_cookie && ( (int) $logged_in_cookie['expiration'] - time() ) > $default_cookie_life ) {
$remember = true;
$token = $logged_in_cookie['token'];
}

wp_set_auth_cookie( $user_id, $remember, $token );
wp_set_auth_cookie( $user_id, $remember, '', $token );
}
}

Loading