Token null on modified response
-
I tried to modify “JWT_AUTH_VALID_CREDENTIAL_RESPONSE” like shown in the docs.
But as soon as I do this (using a simple plugin for this) the token is null (although the reponse still says success:true).
Even with no changes to the reponse function that happens.
/** * Modify the response of valid credential. * * @param array $response The default valid credential response. * @param WP_User $user The authenticated user. * . * @return array The valid credential response. */ add_filter( 'jwt_auth_valid_credential_response', function ( $response, $user ) { $response = array( 'success' => true, 'statusCode' => 200, 'code' => 'jwt_auth_valid_credential', 'message' => __( 'Credential is valid', 'jwt-auth' ), 'data' => array( 'token' => $token, 'id' => $user->ID, 'email' => $user->user_email, 'nicename' => $user->user_nicename, 'firstName' => $user->first_name, 'lastName' => $user->last_name, 'displayName' => $user->display_name, ), ); return $response; }, 10, 2 );
Then I tried to modify the “JWT_AUTH_VALID_TOKEN_RESPONSE”, which works fine.
Any idea what’s wrong with the modified “JWT_AUTH_VALID_CREDENTIAL_RESPONSE”?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Token null on modified response’ is closed to new replies.