Skip to content

Commit 533f786

Browse files
committed
Add filter to signal error for WP-API v2
WP-API v2 uses filter 'rest_authentication_errors' to check for authentication errors. Add filter to return a proper error to WP-API v2 when something went wrong with OAuth authentication.
1 parent 4ca54cf commit 533f786

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/class-wp-json-authentication.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ public function __construct() {
2626
}
2727

2828
add_filter( 'json_check_authentication', array( $this, 'authenticate' ), 0 );
29+
add_filter( 'rest_authentication_errors', array( $this, 'get_authentication_errors' ), 0 );
2930
}
3031

3132
abstract public function authenticate( $user );
3233

34+
abstract public function get_authentication_errors( $value );
35+
3336
public function get_consumer( $key ) {
3437
$this->should_attempt = false;
3538

0 commit comments

Comments
 (0)