Skip to content

Fixes inconsistent error messages#174

Merged
jasonbahl merged 2 commits intowp-graphql:developfrom
creative-andrew:fix/inconsistent-error-messages-wp-graphql-jwt-authentication
Oct 24, 2024
Merged

Fixes inconsistent error messages#174
jasonbahl merged 2 commits intowp-graphql:developfrom
creative-andrew:fix/inconsistent-error-messages-wp-graphql-jwt-authentication

Conversation

@creative-andrew
Copy link
Copy Markdown

@creative-andrew creative-andrew commented Feb 3, 2023

Most errors messages defined by the plugin are normally full messages:

E.g. throw new UserError( __( 'The JWT token could not be returned', 'wp-graphql-jwt-authentication' ) );

Nevertheless, on some occasions, it is returning the error code.

$error_code = ! empty( $user->get_error_code() ) ? $user->get_error_code() : 'invalid login';

or both combined:

throw new \Exception( $token->get_error_code() . ' | ' . $token->get_error_message() );

This PR adds consistency in terms of how the error is checked (is_wp_error()') and what is returned (error->get_error_message(). It also escapes the output for improved security.

@jasonbahl jasonbahl merged commit 9e96a5f into wp-graphql:develop Oct 24, 2024
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

Successfully merging this pull request may close these issues.

2 participants