Ticket #32429: 32429.2.diff
File 32429.2.diff, 3.0 KB (added by , 10 years ago) |
---|
-
src/wp-includes/user.php
2268 2268 $wp_hasher = new PasswordHash( 8, true ); 2269 2269 } 2270 2270 2271 if ( $wp_hasher->CheckPassword( $key, $row->user_activation_key ) ) 2271 list( $pass_key, $pass_exp ) = explode( ':', $row->user_activation_key ); 2272 2273 $expire_time = apply_filters( 'time_to_expire_password_keys', '24 hours' ); 2274 2275 if( time() > strtotime( $expire_time, $pass_exp ) ) 2276 return new WP_Error( 'expired_key', __( 'Your password reset token has expired.' ) ); 2277 2278 if ( $wp_hasher->CheckPassword( $key, $pass_key ) ) 2272 2279 return get_userdata( $row->ID ); 2273 2280 2274 2281 if ( $key === $row->user_activation_key ) { -
src/wp-login.php
357 357 require_once ABSPATH . WPINC . '/class-phpass.php'; 358 358 $wp_hasher = new PasswordHash( 8, true ); 359 359 } 360 $hashed = $wp_hasher->HashPassword( $key ); 360 $time = time(); 361 $hashed = $wp_hasher->HashPassword( $key ) . ':' . $time; 361 362 $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user_login ) ); 362 363 363 364 $message = __('Someone requested that the password be reset for the following account:') . "\r\n\r\n"; … … 365 366 $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; 366 367 $message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n\r\n"; 367 368 $message .= __('To reset your password, visit the following address:') . "\r\n\r\n"; 368 $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key &login=" . rawurlencode($user_login), 'login') . ">\r\n";369 $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key:$time&login=" . rawurlencode($user_login), 'login') . ">\r\n"; 369 370 370 371 if ( is_multisite() ) 371 372 $blogname = $GLOBALS['current_site']->site_name; … … 525 526 if ( 'invalidkey' == $_GET['error'] ) 526 527 $errors->add( 'invalidkey', __( 'Sorry, that key does not appear to be valid.' ) ); 527 528 elseif ( 'expiredkey' == $_GET['error'] ) 528 $errors->add( 'expiredkey', __( 'Sorry, that key has expired. Please try again.' ) ); 529 $errors->add( 'expiredkey', __( 'Sorry, your password reset link has expired. Please request a new link below.' ) ); 530 529 531 } 530 532 531 533 $lostpassword_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; … … 588 590 list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) ); 589 591 $rp_cookie = 'wp-resetpass-' . COOKIEHASH; 590 592 if ( isset( $_GET['key'] ) ) { 591 $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) ); 593 list( $key, $exp ) = explode( ':', wp_unslash( $_GET['key'] ) ); 594 $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), $key ); 592 595 setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); 593 596 wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) ); 594 597 exit;