Ticket #53634: 53634.3.diff
File 53634.3.diff, 2.4 KB (added by , 2 years ago) |
---|
-
src/wp-includes/user.php
3050 3050 $user_login = $_POST['user_login']; 3051 3051 } 3052 3052 3053 $user_login = trim( wp_unslash( $user_login ) ); 3054 3053 3055 if ( empty( $user_login ) ) { 3054 3056 $errors->add( 'empty_username', __( '<strong>Error:</strong> Please enter a username or email address.' ) ); 3055 3057 } elseif ( strpos( $user_login, '@' ) ) { 3056 $user_data = get_user_by( 'email', trim( wp_unslash( $user_login ) ) ); 3058 $user_data = get_user_by( 'email', $user_login ); 3059 3057 3060 if ( empty( $user_data ) ) { 3061 $user_data = get_user_by( 'login', $user_login ); 3062 } 3063 3064 if ( empty( $user_data ) ) { 3058 3065 $errors->add( 'invalid_email', __( '<strong>Error:</strong> There is no account with that username or email address.' ) ); 3059 3066 } 3060 3067 } else { 3061 $user_data = get_user_by( 'login', trim( wp_unslash( $user_login ) ));3068 $user_data = get_user_by( 'login', $user_login ); 3062 3069 } 3063 3070 3064 3071 /** -
tests/phpunit/tests/user/retrievePassword.php
47 47 * @ticket 54690 48 48 */ 49 49 public function test_retrieve_password_reset_notification_email() { 50 $message = 'Sending password reset notification email failed.'; 51 $this->assertNotWPError( retrieve_password( $this->user->user_login ), $message ); 50 $this->assertNotWPError( retrieve_password( $this->user->user_login ), 'Sending password reset notification email failed.' ); 52 51 } 53 52 54 53 /** … … 64 63 } 65 64 ); 66 65 67 $message = 'Sending password reset notification email succeeded.'; 68 $this->assertWPError( retrieve_password( $this->user->user_login ), $message ); 66 $this->assertWPError( retrieve_password( $this->user->user_login ), 'Sending password reset notification email succeeded.' ); 69 67 } 68 69 /** 70 * @ticket 53634 71 */ 72 public function test_retrieve_password_should_fetch_user_by_login_if_not_found_by_email() { 73 self::factory()->user->create( 74 array( 75 'user_login' => 'foo@example.com', 76 'user_email' => 'bar@example.com', 77 ) 78 ); 79 80 $this->assertTrue( retrieve_password( 'foo@example.com' ), 'Fetching user by login failed.' ); 81 $this->assertTrue( retrieve_password( 'bar@example.com' ), 'Fetching user by email failed.' ); 82 } 70 83 }