Changeset 50114 for trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php
- Timestamp:
- 01/31/2021 07:02:30 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php
r50065 r50114 111 111 */ 112 112 public function get_items_permissions_check( $request ) { 113 return $this->do_permissions_check( $request ); 113 $user = $this->get_user( $request ); 114 115 if ( is_wp_error( $user ) ) { 116 return $user; 117 } 118 119 if ( ! current_user_can( 'list_app_passwords', $user->ID ) ) { 120 return new WP_Error( 121 'rest_cannot_list_application_passwords', 122 __( 'Sorry, you are not allowed to list application passwords for this user.' ), 123 array( 'status' => rest_authorization_required_code() ) 124 ); 125 } 126 127 return true; 114 128 } 115 129 … … 150 164 */ 151 165 public function get_item_permissions_check( $request ) { 152 return $this->do_permissions_check( $request ); 166 $user = $this->get_user( $request ); 167 168 if ( is_wp_error( $user ) ) { 169 return $user; 170 } 171 172 if ( ! current_user_can( 'read_app_password', $user->ID, $request['uuid'] ) ) { 173 return new WP_Error( 174 'rest_cannot_read_application_password', 175 __( 'Sorry, you are not allowed to read this application password.' ), 176 array( 'status' => rest_authorization_required_code() ) 177 ); 178 } 179 180 return true; 153 181 } 154 182 … … 180 208 */ 181 209 public function create_item_permissions_check( $request ) { 182 return $this->do_permissions_check( $request ); 210 $user = $this->get_user( $request ); 211 212 if ( is_wp_error( $user ) ) { 213 return $user; 214 } 215 216 if ( ! current_user_can( 'create_app_password', $user->ID ) ) { 217 return new WP_Error( 218 'rest_cannot_create_application_passwords', 219 __( 'Sorry, you are not allowed to create application passwords for this user.' ), 220 array( 'status' => rest_authorization_required_code() ) 221 ); 222 } 223 224 return true; 183 225 } 184 226 … … 249 291 */ 250 292 public function update_item_permissions_check( $request ) { 251 return $this->do_permissions_check( $request ); 293 $user = $this->get_user( $request ); 294 295 if ( is_wp_error( $user ) ) { 296 return $user; 297 } 298 299 if ( ! current_user_can( 'edit_app_password', $user->ID, $request['uuid'] ) ) { 300 return new WP_Error( 301 'rest_cannot_edit_application_password', 302 __( 'Sorry, you are not allowed to edit this application password.' ), 303 array( 'status' => rest_authorization_required_code() ) 304 ); 305 } 306 307 return true; 252 308 } 253 309 … … 309 365 */ 310 366 public function delete_items_permissions_check( $request ) { 311 return $this->do_permissions_check( $request ); 367 $user = $this->get_user( $request ); 368 369 if ( is_wp_error( $user ) ) { 370 return $user; 371 } 372 373 if ( ! current_user_can( 'delete_app_passwords', $user->ID ) ) { 374 return new WP_Error( 375 'rest_cannot_delete_application_passwords', 376 __( 'Sorry, you are not allowed to delete application passwords for this user.' ), 377 array( 'status' => rest_authorization_required_code() ) 378 ); 379 } 380 381 return true; 312 382 } 313 383 … … 350 420 */ 351 421 public function delete_item_permissions_check( $request ) { 352 return $this->do_permissions_check( $request ); 422 $user = $this->get_user( $request ); 423 424 if ( is_wp_error( $user ) ) { 425 return $user; 426 } 427 428 if ( ! current_user_can( 'delete_app_password', $user->ID, $request['uuid'] ) ) { 429 return new WP_Error( 430 'rest_cannot_delete_application_password', 431 __( 'Sorry, you are not allowed to delete this application password.' ), 432 array( 'status' => rest_authorization_required_code() ) 433 ); 434 } 435 436 return true; 353 437 } 354 438 … … 458 542 * 459 543 * @since 5.6.0 544 * @deprecated 5.7.0 Use `edit_user` directly or one of the specific meta capabilities introduced in 5.7.0. 460 545 * 461 546 * @param WP_REST_Request $request … … 463 548 */ 464 549 protected function do_permissions_check( $request ) { 550 _deprecated_function( __METHOD__, '5.7.0' ); 551 465 552 $user = $this->get_user( $request ); 466 553
Note: See TracChangeset
for help on using the changeset viewer.