App Passwords: Unify availability language.

Previously App Passwords used a mix of "enabled" and "available". We've now standardized on using "available".

Additionally, we now use a 501 status code when indicating that App Passwords is not available.

Props SergeyBiryukov, ocean90, TimothyBlynJacobs.
Fixes #51513.

Built from https://develop.svn.wordpress.org/trunk@49617


git-svn-id: http://core.svn.wordpress.org/trunk@49355 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
TimothyBlynJacobs 2020-11-16 22:42:04 +00:00
parent aceaf33edd
commit d9b35c8e98
4 changed files with 16 additions and 10 deletions

View File

@ -90,15 +90,16 @@ if ( is_wp_error( $is_valid ) ) {
if ( ! wp_is_application_passwords_available_for_user( $user ) ) { if ( ! wp_is_application_passwords_available_for_user( $user ) ) {
if ( wp_is_application_passwords_available() ) { if ( wp_is_application_passwords_available() ) {
$message = __( 'Application passwords are not enabled for your account. Please contact the site administrator for assistance.' ); $message = __( 'Application passwords are not available for your account. Please contact the site administrator for assistance.' );
} else { } else {
$message = __( 'Application passwords are not enabled.' ); $message = __( 'Application passwords are not available.' );
} }
wp_die( wp_die(
$message, $message,
__( 'Cannot Authorize Application' ), __( 'Cannot Authorize Application' ),
array( array(
'response' => 501,
'link_text' => __( 'Go Back' ), 'link_text' => __( 'Go Back' ),
'link_url' => $reject_url ? add_query_arg( 'error', 'disabled', $reject_url ) : admin_url(), 'link_url' => $reject_url ? add_query_arg( 'error', 'disabled', $reject_url ) : admin_url(),
) )

View File

@ -503,8 +503,8 @@ class WP_REST_Application_Passwords_Controller extends WP_REST_Controller {
if ( ! wp_is_application_passwords_available() ) { if ( ! wp_is_application_passwords_available() ) {
return new WP_Error( return new WP_Error(
'application_passwords_disabled', 'application_passwords_disabled',
__( 'Application passwords are not enabled.' ), __( 'Application passwords are not available.' ),
array( 'status' => 500 ) array( 'status' => 501 )
); );
} }
@ -547,8 +547,8 @@ class WP_REST_Application_Passwords_Controller extends WP_REST_Controller {
if ( ! wp_is_application_passwords_available_for_user( $user ) ) { if ( ! wp_is_application_passwords_available_for_user( $user ) ) {
return new WP_Error( return new WP_Error(
'application_passwords_disabled_for_user', 'application_passwords_disabled_for_user',
__( 'Application passwords are not enabled for your account. Please contact the site administrator for assistance.' ), __( 'Application passwords are not available for your account. Please contact the site administrator for assistance.' ),
array( 'status' => 500 ) array( 'status' => 501 )
); );
} }

View File

@ -350,10 +350,15 @@ function wp_authenticate_application_password( $input_user, $username, $password
__( 'Unknown username. Check again or try your email address.' ) __( 'Unknown username. Check again or try your email address.' )
); );
} }
} elseif ( ! wp_is_application_passwords_available_for_user( $user ) ) { } elseif ( ! wp_is_application_passwords_available() ) {
$error = new WP_Error( $error = new WP_Error(
'application_passwords_disabled', 'application_passwords_disabled',
__( 'Application passwords are disabled for the requested user.' ) 'Application passwords are not available.'
);
} elseif ( ! wp_is_application_passwords_available_for_user( $user ) ) {
$error = new WP_Error(
'application_passwords_disabled_for_user',
__( 'Application passwords are not available for your account. Please contact the site administrator for assistance.' )
); );
} }
@ -4131,7 +4136,7 @@ function wp_is_application_passwords_available() {
} }
/** /**
* Checks if Application Passwords is enabled for a specific user. * Checks if Application Passwords is available for a specific user.
* *
* By default all users can use Application Passwords. Use {@see 'wp_is_application_passwords_available_for_user'} * By default all users can use Application Passwords. Use {@see 'wp_is_application_passwords_available_for_user'}
* to restrict availability to certain users. * to restrict availability to certain users.

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.6-beta4-49616'; $wp_version = '5.6-beta4-49617';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.