Make WordPress Core

Changeset 49617


Ignore:
Timestamp:
11/16/2020 10:40:11 PM (3 years ago)
Author:
TimothyBlynJacobs
Message:

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.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/authorize-application.php

    r49562 r49617  
    9191if ( ! wp_is_application_passwords_available_for_user( $user ) ) {
    9292    if ( wp_is_application_passwords_available() ) {
    93         $message = __( 'Application passwords are not enabled for your account. Please contact the site administrator for assistance.' );
     93        $message = __( 'Application passwords are not available for your account. Please contact the site administrator for assistance.' );
    9494    } else {
    95         $message = __( 'Application passwords are not enabled.' );
     95        $message = __( 'Application passwords are not available.' );
    9696    }
    9797
     
    100100        __( 'Cannot Authorize Application' ),
    101101        array(
     102            'response'  => 501,
    102103            'link_text' => __( 'Go Back' ),
    103104            'link_url'  => $reject_url ? add_query_arg( 'error', 'disabled', $reject_url ) : admin_url(),
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php

    r49276 r49617  
    504504            return new WP_Error(
    505505                'application_passwords_disabled',
    506                 __( 'Application passwords are not enabled.' ),
    507                 array( 'status' => 500 )
     506                __( 'Application passwords are not available.' ),
     507                array( 'status' => 501 )
    508508            );
    509509        }
     
    548548            return new WP_Error(
    549549                'application_passwords_disabled_for_user',
    550                 __( 'Application passwords are not enabled for your account. Please contact the site administrator for assistance.' ),
    551                 array( 'status' => 500 )
     550                __( 'Application passwords are not available for your account. Please contact the site administrator for assistance.' ),
     551                array( 'status' => 501 )
    552552            );
    553553        }
  • trunk/src/wp-includes/user.php

    r49475 r49617  
    351351            );
    352352        }
     353    } elseif ( ! wp_is_application_passwords_available() ) {
     354        $error = new WP_Error(
     355            'application_passwords_disabled',
     356            'Application passwords are not available.'
     357        );
    353358    } elseif ( ! wp_is_application_passwords_available_for_user( $user ) ) {
    354359        $error = new WP_Error(
    355             'application_passwords_disabled',
    356             __( 'Application passwords are disabled for the requested user.' )
     360            'application_passwords_disabled_for_user',
     361            __( 'Application passwords are not available for your account. Please contact the site administrator for assistance.' )
    357362        );
    358363    }
     
    41324137
    41334138/**
    4134  * Checks if Application Passwords is enabled for a specific user.
     4139 * Checks if Application Passwords is available for a specific user.
    41354140 *
    41364141 * By default all users can use Application Passwords. Use {@see 'wp_is_application_passwords_available_for_user'}
  • trunk/tests/phpunit/tests/auth.php

    r49603 r49617  
    528528        $error = wp_authenticate_application_password( null, self::$_user->user_login, 'password' );
    529529        $this->assertWPError( $error );
    530         $this->assertSame( 'application_passwords_disabled', $error->get_error_code() );
     530        $this->assertSame( 'application_passwords_disabled_for_user', $error->get_error_code() );
    531531    }
    532532
  • trunk/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php

    r49603 r49617  
    113113
    114114        $response = rest_do_request( '/wp/v2/users/me/application-passwords' );
    115         $this->assertErrorResponse( 'application_passwords_disabled', $response, 500 );
     115        $this->assertErrorResponse( 'application_passwords_disabled', $response, 501 );
    116116    }
    117117
     
    124124
    125125        $response = rest_do_request( '/wp/v2/users/me/application-passwords' );
    126         $this->assertErrorResponse( 'application_passwords_disabled_for_user', $response, 500 );
     126        $this->assertErrorResponse( 'application_passwords_disabled_for_user', $response, 501 );
    127127    }
    128128
Note: See TracChangeset for help on using the changeset viewer.