From 8aa657443e757ad4adceeda07eefb438ae5b1c42 Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Thu, 29 Jan 2009 21:30:16 +0000 Subject: [PATCH] Much better handling of wp-login.php page load. See #8938 props wnorris. git-svn-id: https://develop.svn.wordpress.org/trunk@10463 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/pluggable.php | 7 +------ wp-includes/user.php | 12 ++++++------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index f615adc4c5..d9f5cd7448 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -426,15 +426,10 @@ function wp_authenticate($username, $password) { $user = apply_filters('authenticate', null, $username, $password); - if ( ($user == null ) ) { - // TODO slight hack to handle initial load of wp-login.php - if ( empty($username) && empty($password) && ($GLOBALS['pagenow'] == 'wp-login.php' ) ) { - $user = new WP_Error('',''); //No Error - } else { + if ( $user == null ) { // TODO what should the error message be? (Or would these even happen?) // Only needed if all authentication handlers fail to return anything. $user = new WP_Error('authentication_failed', __('ERROR: Invalid username or incorrect password.')); - } } if (is_wp_error($user)) { diff --git a/wp-includes/user.php b/wp-includes/user.php index 3c61ad6ecd..5a31e5e836 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -50,8 +50,13 @@ function wp_signon( $credentials = '', $secure_cookie = '' ) { $user = wp_authenticate($credentials['user_login'], $credentials['user_password']); - if ( is_wp_error($user) ) + if ( is_wp_error($user) ) { + if ( $user->get_error_codes() == array('empty_username', 'empty_password') ) { + $user = new WP_Error('', ''); + } + return $user; + } wp_set_auth_cookie($user->ID, $credentials['remember'], $secure_cookie); do_action('wp_login', $credentials['user_login']); @@ -66,11 +71,6 @@ add_filter('authenticate', 'wp_authenticate_username_password', 20, 3); function wp_authenticate_username_password($user, $username, $password) { if ( is_a($user, 'WP_User') ) { return $user; } - // TODO slight hack to handle initial load of wp-login.php - if ( (empty($username) && empty($password)) && $GLOBALS['pagenow'] == 'wp-login.php' ) { - return $user; - } - if ( empty($username) || empty($password) ) { $error = new WP_Error();