Much better handling of wp-login.php page load. See #8938 props wnorris.
git-svn-id: http://svn.automattic.com/wordpress/trunk@10463 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
aea6896bf8
commit
8855daf707
|
@ -426,16 +426,11 @@ function wp_authenticate($username, $password) {
|
||||||
|
|
||||||
$user = apply_filters('authenticate', null, $username, $password);
|
$user = apply_filters('authenticate', null, $username, $password);
|
||||||
|
|
||||||
if ( ($user == null ) ) {
|
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 {
|
|
||||||
// TODO what should the error message be? (Or would these even happen?)
|
// TODO what should the error message be? (Or would these even happen?)
|
||||||
// Only needed if all authentication handlers fail to return anything.
|
// Only needed if all authentication handlers fail to return anything.
|
||||||
$user = new WP_Error('authentication_failed', __('<strong>ERROR</strong>: Invalid username or incorrect password.'));
|
$user = new WP_Error('authentication_failed', __('<strong>ERROR</strong>: Invalid username or incorrect password.'));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (is_wp_error($user)) {
|
if (is_wp_error($user)) {
|
||||||
do_action('wp_login_failed', $username);
|
do_action('wp_login_failed', $username);
|
||||||
|
|
|
@ -50,8 +50,13 @@ function wp_signon( $credentials = '', $secure_cookie = '' ) {
|
||||||
|
|
||||||
$user = wp_authenticate($credentials['user_login'], $credentials['user_password']);
|
$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;
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
wp_set_auth_cookie($user->ID, $credentials['remember'], $secure_cookie);
|
wp_set_auth_cookie($user->ID, $credentials['remember'], $secure_cookie);
|
||||||
do_action('wp_login', $credentials['user_login']);
|
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) {
|
function wp_authenticate_username_password($user, $username, $password) {
|
||||||
if ( is_a($user, 'WP_User') ) { return $user; }
|
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) ) {
|
if ( empty($username) || empty($password) ) {
|
||||||
$error = new WP_Error();
|
$error = new WP_Error();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue