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

JWT token could not be returned #69

Closed
henrikwirth opened this issue Feb 1, 2020 · 3 comments · Fixed by #72
Closed

JWT token could not be returned #69

henrikwirth opened this issue Feb 1, 2020 · 3 comments · Fixed by #72
Assignees

Comments

@henrikwirth
Copy link
Collaborator

There seems to be a bug with the newest versions:

WPGraphQL: 0.6.1
JWT: 0.3.5

When doing the registerUser mutation like so:

mutation RegisterUser($input: RegisterUserInput!) {
  registerUser(input: $input) {
    user {
      jwtAuthExpiration
      jwtUserSecret
      jwtRefreshToken
      isJwtAuthSecretRevoked
      jwtAuthToken
    }
  }
}

The user gets registered, but the response is the following:

{
  "errors": [
    {
      "message": "The user secret could not be returned",
      "category": "user",
      "locations": [
        {
          "line": 5,
          "column": 7
        }
      ],
      "path": [
        "registerUser",
        "user",
        "jwtUserSecret"
      ]
    },
    {
      "message": "The JWT token could not be returned",
      "category": "user",
      "locations": [
        {
          "line": 6,
          "column": 7
        }
      ],
      "path": [
        "registerUser",
        "user",
        "jwtRefreshToken"
      ]
    },
    {
      "message": "The JWT token could not be returned",
      "category": "user",
      "locations": [
        {
          "line": 8,
          "column": 7
        }
      ],
      "path": [
        "registerUser",
        "user",
        "jwtAuthToken"
      ]
    }
  ],
  "data": {
    "registerUser": {
      "user": {
        "jwtAuthExpiration": "1580566063",
        "jwtUserSecret": null,
        "jwtRefreshToken": null,
        "isJwtAuthSecretRevoked": false,
        "jwtAuthToken": null
      }
    }
  }
}

So it seems for some reason inside ManageTokens.php the following calls don't work as intended:

  • Auth::get_user_jwt_secret
  • Auth:: get_token
  • Auth:: get_refresh_token

Also the error message of refresh token should be different to the one from the token.

@jasonbahl
Copy link
Collaborator

@henrikwirth just to clarify, this mutation was working on previous versions just fine? Is this a regression or something that's been broken for a while?

@henrikwirth
Copy link
Collaborator Author

henrikwirth commented Feb 13, 2020

@jasonbahl
Copy link
Collaborator

@henrikwirth ok thanks. That helps. I'll see what I can find out!

@jasonbahl jasonbahl self-assigned this Feb 13, 2020
jasonbahl added a commit to jasonbahl/wp-graphql-jwt-authentication that referenced this issue Feb 13, 2020
…tation

- This updates the mutations to expect a User model to be passed through instead of a WP_User object
- This also updates some of the errors to be more clear, passing through WP_Error messages
- This also returns null when the user cannot access the JWT Secret instead of throwing an error.
jasonbahl added a commit that referenced this issue Feb 13, 2020
…ed-after-user-registered

#69 - JWT Tokens could not be returned after regiserUser mutation
jasonbahl added a commit to jasonbahl/wp-graphql-jwt-authentication that referenced this issue Feb 14, 2020
jasonbahl added a commit to jasonbahl/wp-graphql-jwt-authentication that referenced this issue Feb 14, 2020
…ard compatiblity for passing WP_User or User (model) through to some resolvers
jasonbahl added a commit that referenced this issue Feb 14, 2020
…ed-after-user-registered

Bug/#69 jwt could not be returned after user registered
jasonbahl added a commit to jasonbahl/wp-graphql-jwt-authentication that referenced this issue Feb 14, 2020
jasonbahl added a commit that referenced this issue Feb 14, 2020
…ed-after-user-registered

#69 - Backward Compatibility fixes for playing nice with WPGraphQL for WooCommerce
jasonbahl added a commit that referenced this issue Feb 17, 2020
jasonbahl added a commit that referenced this issue Feb 17, 2020
…69-jwt-could-not-be-returned-after-user-registered

# Conflicts:
#	wp-graphql-jwt-authentication.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants