PedroBern / django-graphql-auth

Django registration and authentication with GraphQL.
https://django-graphql-auth.readthedocs.io/en/latest/
MIT License
329 stars 106 forks source link

Can't use user register mutation #84

Open SuciuPatrick opened 3 years ago

SuciuPatrick commented 3 years ago

no Is it a bug? no Is it a new feature? yes Is it a a question? yes Can you reproduce the problem? yes Are you running the latest version? yes Did you check for similar issues? yes Did you perform a cursory search?

Hey Guys,

Whenever I'm trying to call the register mutation I receive this "Please, enter valid credentials". From what it seems, I think the issue comes from the fact that on register it tries to call register_on_login which requires a token.

mutation registerTest {
  register(
    email: "new_user@email.com",
    password1: "123456asda!",
    password2: "123456asda!"
  ) {
    success,
    errors,
    token,
    refreshToken
  }
}

{
  "errors": [
    {
      "message": "Please, enter valid credentials",
      "locations": [
        {
          "line": 29,
          "column": 3
        }
      ],
      "path": [
        "register"
      ]
    }
  ],
  "data": {
    "register": null
  }
}

aniso8601==7.0.0
asgiref==3.3.0
attrs==20.3.0
Django==3.0
django-cors-headers==3.5.0
django-environ==0.4.5
django-filter==2.4.0
django-graphql-auth==0.3.14
django-graphql-jwt==0.3.0
django-storages==1.10.1
graphene==2.1.8
graphene-django==2.13.0
graphql-core==2.3.2
graphql-relay==2.0.1
iniconfig==1.1.1
packaging==20.4
Pillow==8.0.1
pluggy==0.13.1
promise==2.3
psycopg2==2.8.6
py==1.9.0
PyJWT==1.7.1
pyparsing==2.4.7
pytest==6.1.2
pytest-django==4.1.0
pytz==2020.4
Rx==1.6.1
singledispatch==3.4.0.3
six==1.15.0
sqlparse==0.4.1
toml==0.10.2
Unidecode==1.1.1
uWSGI==2.0.19.1
SuciuPatrick commented 3 years ago

So I think I found the issue. I am using that register_mutation_fields because I wanted to remove the username, but if I remove that, it works.

GRAPHQL_AUTH = {
    'LOGIN_ALLOWED_FIELDS': ['email'],
    'USER_NODE_EXCLUDE_FIELDS': ["password"],
     'REGISTER_MUTATION_FIELDS': {
         "email": "String",
     },
}