Authentication: Allow users to log in using their email address.

Introduces `wp_authenticate_email_password()` which is hooked into `authenticate` after `wp_authenticate_username_password()`.

Props Denis-de-Bernardy, ericlewis, vhomenko, MikeHansenMe, swissspidy, ocean90.
Fixes #9568.

git-svn-id: https://develop.svn.wordpress.org/trunk@36617 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90)
2016-02-22 23:14:27 +00:00
parent cde3d4c399
commit 12cf07c669
5 changed files with 101 additions and 5 deletions

View File

@@ -311,4 +311,21 @@ class Tests_Auth extends WP_UnitTestCase {
$check = check_password_reset_key( '', $this->user->user_login );
$this->assertInstanceOf( 'WP_Error', $check );
}
/**
* Ensure users can log in using both their username and their email address.
*
* @ticket 9568
*/
function test_log_in_using_email() {
$user_args = array(
'user_login' => 'johndoe',
'user_email' => 'mail@example.com',
'user_pass' => 'password',
);
$this->factory->user->create( $user_args );
$this->assertInstanceOf( 'WP_User', wp_authenticate( $user_args['user_email'], $user_args['user_pass'] ) );
$this->assertInstanceOf( 'WP_User', wp_authenticate( $user_args['user_login'], $user_args['user_pass'] ) );
}
}