Skip to content

Commit

Permalink
REST API: Only validate token for our namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
eliot-akira committed Jan 15, 2025
1 parent 6019a26 commit cfcfbbc
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions framework/api/rest/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,19 +485,16 @@ function reset_password( $request ) {
* Provide current user to the request.
*/
function rest_pre_dispatch( $result, $server, $request ) {
// Check if this is a Loops & Logic endpoint.
if ( strpos( $request->get_route(), '/' . $this->namespace ) === false ) {

return false; // Not our endpoint, skip validation.

}
// Only validate token for our namespace
if ( strpos( $request->get_route(), '/' . $this->namespace ) === false ) {
return false;
}
if ($request->get_route() !== '/' . $this->namespace . '/token/validate'
&& !empty($user_id = $this->determine_current_user())
&& !is_user_logged_in()
) {
wp_set_current_user($user_id);
}

return $result;
}

Expand Down

0 comments on commit cfcfbbc

Please sign in to comment.