diff --git a/src/wp-includes/class-wp-application-passwords.php b/src/wp-includes/class-wp-application-passwords.php index 38ec4915dea48..b76b5c7e2a5ae 100644 --- a/src/wp-includes/class-wp-application-passwords.php +++ b/src/wp-includes/class-wp-application-passwords.php @@ -94,10 +94,6 @@ public static function create_new_application_password( $user_id, $args = array( return new WP_Error( 'application_password_empty_name', __( 'An application name is required to create an application password.' ), array( 'status' => 400 ) ); } - if ( self::application_name_exists_for_user( $user_id, $args['name'] ) ) { - return new WP_Error( 'application_password_duplicate_name', __( 'Each application name should be unique.' ), array( 'status' => 409 ) ); - } - $new_password = wp_generate_password( static::PW_LENGTH, false ); $hashed_password = wp_hash_password( $new_password ); diff --git a/tests/phpunit/tests/rest-api/application-passwords.php b/tests/phpunit/tests/rest-api/application-passwords.php index a630719ee8921..37c83731bb0d4 100644 --- a/tests/phpunit/tests/rest-api/application-passwords.php +++ b/tests/phpunit/tests/rest-api/application-passwords.php @@ -196,4 +196,14 @@ public function data_update_application_password() { ), ); } + + /** + * @ticket 51941 + */ + public function test_can_create_duplicate_app_password_names() { + $created = WP_Application_Passwords::create_new_application_password( self::$user_id, array( 'name' => 'My App' ) ); + $this->assertNotWPError( $created ); + $created = WP_Application_Passwords::create_new_application_password( self::$user_id, array( 'name' => 'My App' ) ); + $this->assertNotWPError( $created ); + } }