Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for the following warning: "Notice: Function register_rest_route was called incorrectly...." #72

Open
iamanthonyg opened this issue May 9, 2023 · 0 comments

Comments

@iamanthonyg
Copy link

Hi,
I noticed that when I install and access the plugin, it shows the following warning:

Notice: Function register_rest_route was called incorrectly. The REST API route definition for simple-jwt-authentication/v1/token is missing the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as the permission callback. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in C:\wamp\www\woo2\wp-includes\functions.php on line 5865

I have also figured out the solution for this. The solution is to add 'permission_callback' => '__return_true', argument. Following is the complete solution to be implemented in the following file:
wp-content/plugins/simple-jwt-authentication-master/includes/class-simple-jwt-authentication-rest.php

/**
	 * Add the endpoints to the API
	 */
	public function add_api_routes() {
		register_rest_route(
			$this->namespace,
			'token',
			array(
				'methods'  => 'POST',
				'callback' => array( $this, 'generate_token' ),
                'permission_callback' => '__return_true',
			)
		);

		register_rest_route(
			$this->namespace,
			'token/validate',
			array(
				'methods'  => 'POST',
				'callback' => array( $this, 'validate_token' ),
                'permission_callback' => '__return_true',
			)
		);

		register_rest_route(
			$this->namespace,
			'token/refresh',
			array(
				'methods'  => 'POST',
				'callback' => array( $this, 'refresh_token' ),
                'permission_callback' => '__return_true',
			)
		);

		register_rest_route(
			$this->namespace,
			'token/revoke',
			array(
				'methods'  => 'POST',
				'callback' => array( $this, 'revoke_token' ),
                'permission_callback' => '__return_true',
			)
		);

		register_rest_route(
			$this->namespace,
			'token/resetpassword',
			array(
				'methods'  => 'POST',
				'callback' => array( $this, 'reset_password' ),
                'permission_callback' => '__return_true',
			)
		);
	}

I hope you will be able to add the above fix in your next update.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant