WordPress.org

Make WordPress Core

Ticket #8938: wp-auth-2.diff

File wp-auth-2.diff, 1.8 KB (added by wnorris, 5 years ago)

fix error displayed on initial wp-login.php load

  • wp-includes/pluggable.php

     
    426426 
    427427        $user = apply_filters('authenticate', null, $username, $password); 
    428428 
    429         if ( ($user == null ) ) { 
    430                 // TODO slight hack to handle initial load of wp-login.php 
    431                 if ( empty($username) && empty($password) && ($GLOBALS['pagenow'] == 'wp-login.php' ) ) { 
    432                         $user = new WP_Error('',''); //No Error 
    433                 } else { 
     429        if ( $user == null ) { 
    434430                // TODO what should the error message be? (Or would these even happen?) 
    435431                // Only needed if all authentication handlers fail to return anything. 
    436432                $user = new WP_Error('authentication_failed', __('<strong>ERROR</strong>: Invalid username or incorrect password.')); 
    437                 } 
    438433        } 
    439434 
    440435        if (is_wp_error($user)) { 
  • wp-includes/user.php

     
    5050 
    5151        $user = wp_authenticate($credentials['user_login'], $credentials['user_password']); 
    5252 
    53         if ( is_wp_error($user) ) 
     53        if ( is_wp_error($user) ) { 
     54                if ( $user->get_error_codes() == array('empty_username', 'empty_password') ) { 
     55                        $user = new WP_Error('', ''); 
     56                } 
     57 
    5458                return $user; 
     59        } 
    5560 
    5661        wp_set_auth_cookie($user->ID, $credentials['remember'], $secure_cookie); 
    5762        do_action('wp_login', $credentials['user_login']); 
     
    6671function wp_authenticate_username_password($user, $username, $password) { 
    6772        if ( is_a($user, 'WP_User') ) { return $user; } 
    6873 
    69         // TODO slight hack to handle initial load of wp-login.php 
    70         if ( (empty($username) && empty($password)) && $GLOBALS['pagenow'] == 'wp-login.php' ) { 
    71                 return $user; 
    72         } 
    73  
    7474        if ( empty($username) || empty($password) ) { 
    7575                $error = new WP_Error(); 
    7676