WordPress.org

Make WordPress Core

Changeset 29327


Ignore:
Timestamp:
07/29/2014 06:18:58 PM (7 years ago)
Author:
nacin
Message:

Don't pass around the password reset key.

props mdawaffe.
fixes #29060.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-login.php

    r29311 r29327  
    560560case 'resetpass' :
    561561case 'rp' :
    562     $user = check_password_reset_key($_GET['key'], $_GET['login']);
     562    list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) );
     563    $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
     564    if ( isset( $_GET['key'] ) ) {
     565        $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) );
     566        setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
     567        wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) );
     568        exit;
     569    }
     570
     571    list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
     572
     573    $user = check_password_reset_key( $rp_key, $rp_login );
    563574
    564575    if ( is_wp_error($user) ) {
     576        setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
    565577        if ( $user->get_error_code() === 'expired_key' )
    566578            wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) );
     
    587599    if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) {
    588600        reset_password($user, $_POST['pass1']);
     601        setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
    589602        login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>' );
    590603        login_footer();
     
    598611
    599612?>
    600 <form name="resetpassform" id="resetpassform" action="<?php echo esc_url( site_url( 'wp-login.php?action=resetpass&key=' . urlencode( $_GET['key'] ) . '&login=' . urlencode( $_GET['login'] ), 'login_post' ) ); ?>" method="post" autocomplete="off">
    601     <input type="hidden" id="user_login" value="<?php echo esc_attr( $_GET['login'] ); ?>" autocomplete="off" />
     613<form name="resetpassform" id="resetpassform" action="<?php echo esc_url( site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" method="post" autocomplete="off">
     614    <input type="hidden" id="user_login" value="<?php echo esc_attr( $rp_login ); ?>" autocomplete="off" />
    602615
    603616    <p>
Note: See TracChangeset for help on using the changeset viewer.