Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions class-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ public function is_error_response( $response ) {
* @return WP_REST_Response | Array Returns WP_REST_Response or token's $payload.
*/
public function validate_token( $return_response = true ) {
global $l10n;

$has_l10n = isset( $l10n[ 'jwt-auth' ] );

/**
* Looking for the HTTP_AUTHORIZATION header, if not present just
* return the user.
Expand All @@ -390,7 +394,7 @@ public function validate_token( $return_response = true ) {
'success' => false,
'statusCode' => 401,
'code' => 'jwt_auth_no_auth_header',
'message' => __( 'Authorization header not found.', 'jwt-auth' ),
'message' => $has_l10n ? __( 'Authorization header not found.', 'jwt-auth' ) : 'Authorization header not found.',
'data' => array(),
),
401
Expand All @@ -409,7 +413,7 @@ public function validate_token( $return_response = true ) {
'success' => false,
'statusCode' => 401,
'code' => 'jwt_auth_bad_auth_header',
'message' => __( 'Authorization header malformed.', 'jwt-auth' ),
'message' => $has_l10n ? __( 'Authorization header malformed.', 'jwt-auth' ) : 'Authorization header malformed.',
'data' => array(),
),
401
Expand All @@ -425,7 +429,7 @@ public function validate_token( $return_response = true ) {
'success' => false,
'statusCode' => 401,
'code' => 'jwt_auth_bad_config',
'message' => __( 'JWT is not configured properly.', 'jwt-auth' ),
'message' => $has_l10n ? __( 'JWT is not configured properly.', 'jwt-auth' ) : 'JWT is not configured properly.',
'data' => array(),
),
401
Expand All @@ -445,7 +449,7 @@ public function validate_token( $return_response = true ) {
'success' => false,
'statusCode' => 401,
'code' => 'jwt_auth_bad_iss',
'message' => __( 'The iss do not match with this server.', 'jwt-auth' ),
'message' => $has_l10n ? __( 'The iss do not match with this server.', 'jwt-auth' ) : 'The iss do not match with this server.',
'data' => array(),
),
401
Expand All @@ -460,7 +464,7 @@ public function validate_token( $return_response = true ) {
'success' => false,
'statusCode' => 401,
'code' => 'jwt_auth_bad_request',
'message' => __( 'User ID not found in the token.', 'jwt-auth' ),
'message' => $has_l10n ? __( 'User ID not found in the token.', 'jwt-auth' ) : 'User ID not found in the token.',
'data' => array(),
),
401
Expand All @@ -477,7 +481,7 @@ public function validate_token( $return_response = true ) {
'success' => false,
'statusCode' => 401,
'code' => 'jwt_auth_invalid_token',
'message' => __( "Invalid token", 'jwt-auth' ),
'message' => $has_l10n ? __( "Invalid token", 'jwt-auth' ) : "Invalid token",
'data' => array(),
),
401
Expand All @@ -494,7 +498,7 @@ public function validate_token( $return_response = true ) {
'success' => false,
'statusCode' => 401,
'code' => 'jwt_auth_obsolete_token',
'message' => __( 'Token is obsolete', 'jwt-auth' ),
'message' => $has_l10n ? __( 'Token is obsolete', 'jwt-auth' ) : 'Token is obsolete',
'data' => array(),
),
401
Expand All @@ -510,7 +514,7 @@ public function validate_token( $return_response = true ) {
'success' => true,
'statusCode' => 200,
'code' => 'jwt_auth_valid_token',
'message' => __( 'Token is valid', 'jwt-auth' ),
'message' => $has_l10n ? __( 'Token is valid', 'jwt-auth' ) : 'Token is valid',
'data' => array(),
);

Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ You can help this plugin stay alive and maintained by giving **5 Stars** Rating/

== Changelog ==
= 3.0.x =
- Fix: String translation is invoked before gettext domain is loaded.
- Fix: Prioritise authentication with user credentials over refresh token if both are sent.

= 3.0.2 =
Expand Down