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

registration: matching query does not exist #140

Open
spavlovich001 opened this issue Jan 16, 2022 · 0 comments
Open

registration: matching query does not exist #140

spavlovich001 opened this issue Jan 16, 2022 · 0 comments

Comments

@spavlovich001
Copy link

spavlovich001 commented Jan 16, 2022

# django
Django==3.2.4
django-filter==2.4.0
django-debug-toolbar==3.2.1
django-extensions==3.1.3
django-cors-headers==3.7.0
django-model-utils==4.1.1

# rest
djangorestframework==3.12.4

# db
psycopg2-binary==2.8.6

# graphql
graphene-django==2.15.0
django-graphql-auth==0.3.16
django-graphql-ratelimit==1.0.1
mutation {
  register(
    email: "new_user111@email.com",
    username: "aaa",
    password1: "123456super",
    password2: "123456super",
  ) {
    success,
    errors,
    token,
    refreshToken
  }
}

out:

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

in django console:

--===============3534020390567698451==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

127.0.0.1:8000

Hello aaa!

Please activate your account on the link:

http://127.0.0.1:8000/activate/eyJlbWFpbCI6Im5ld191c2VyMTExQGVtYWlsLmNvbSIsImFjdGlvbiI6ImFjdGl2YXRpb24ifQ:1n95Ft:Umd3bA31DW1n1XTdKVw9HHLlJrcIDt8_G48iZEkU6mk

--===============3534020390567698451==
Content-Type: text/html; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

<h3>127.0.0.1:8000</h3>

<p>Hello aaa!</p>

<p>Please activate your account on the link:</p>

<p>http://127.0.0.1:8000/activate/eyJlbWFpbCI6Im5ld191c2VyMTExQGVtYWlsLmNvbSIsImFjdGlvbiI6ImFjdGl2YXRpb24ifQ:1n95Ft:Umd3bA31DW1n1XTdKVw9HHLlJrcIDt8_G48iZEkU6mk</p>

--===============3534020390567698451==--

-------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/promise/promise.py", line 489, in _resolve_from_executor
    executor(resolve, reject)
  File "/usr/local/lib/python3.10/site-packages/promise/promise.py", line 756, in executor
    return resolve(f(*args, **kwargs))
  File "/usr/local/lib/python3.10/site-packages/graphql/execution/middleware.py", line 75, in make_it_promise
    return next(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/graphql_auth/bases.py", line 31, in mutate
    return cls.resolve_mutation(root, info, **input)
  File "/usr/local/lib/python3.10/site-packages/graphql_auth/mixins.py", line 122, in resolve_mutation
    payload = cls.login_on_register(
  File "/usr/local/lib/python3.10/site-packages/graphql_jwt/decorators.py", line 110, in wrapper
    result = f(cls, root, info, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/graphql_jwt/decorators.py", line 90, in wrapper
    raise exceptions.JSONWebTokenError(
graphql.error.located_error.GraphQLLocatedError: Please, enter valid credentials

in urls.py

from apps.user.views.user import ActivateView

path(r"activate/<str:token>", ActivateView.as_view()),

in views.user

from django.http import HttpResponseRedirect, JsonResponse
from django.views import View
from graphql_auth.models import UserStatus

class ActivateView(View):
    def get(self, request, **kwargs):
    ┆   try:
    ┆   ┆   token = str(kwargs.get("token"))
    ┆   ┆   print("zzzzzzzzzzzzzzzzzzz:" + token)
    ┆   ┆   UserStatus.verify(token=token)
    ┆   except Exception as e:
    ┆   ┆   print(e)
    ┆   ┆   # return HttpResponseRedirect("/some/error/url")
    ┆   # return HttpResponseRedirect("/activate/thankyou")
    ┆   return JsonResponse({"aaa": "bbb"})
curl -X GET http://127.0.0.1:8000/activate/eyJlbWFpbCI6Im5ld191c2VyMTExQGVtYWlsLmNvbSIsImFjdGlvbiI6ImFjdGl2YXRpb24ifQ:1n95Ft:Umd3bA31DW1n1XTdKVw9HHLlJrcIDt8_G48iZEkU6mk
[16/Jan/2022 13:10:45] "GET /activate/eyJlbWFpbCI6Im5ld191c2VyMTExQGVtYWlsLmNvbSIsImFjdGlvbiI6ImFjdGl2YXRpb24ifQ:1n95Ft:Umd3bA31DW1n1XTdKVw9HHLlJrcIDt8_G48iZEkU6mk HTTP/1.1" 301 0
zzzzzzzzzzzzzzzzzzz:eyJlbWFpbCI6Im5ld191c2VyMTExQGVtYWlsLmNvbSIsImFjdGlvbiI6ImFjdGl2YXRpb24ifQ:1n95Ft:Umd3bA31DW1n1XTdKVw9HHLlJrcIDt8_G48iZEkU6mk
ExtUser matching query does not exist.
mutation {
  verifyAccount(token: "eyJlbWFpbCI6Im5ld191c2VyMTExQGVtYWlsLmNvbSIsImFjdGlvbiI6ImFjdGl2YXRpb24ifQ:1n95Ft:Umd3bA31DW1n1XTdKVw9HHLlJrcIDt8_G48iZEkU6mk") {
    success,
    errors
  }
}

out:

{
  "errors": [
    {
      "message": "ExtUser matching query does not exist.",
      "locations": [
        {
          "line": 230,
          "column": 3
        }
      ],
      "path": [
        "verifyAccount"
      ]
    }
  ],
  "data": {
    "verifyAccount": null
  }
}

in django console:

[16/Jan/2022 17:26:15] "POST /graphql/ HTTP/1.1" 200 158
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/promise/promise.py", line 489, in _resolve_from_executor
    executor(resolve, reject)
  File "/usr/local/lib/python3.8/site-packages/promise/promise.py", line 756, in executor
    return resolve(f(*args, **kwargs))
  File "/usr/local/lib/python3.8/site-packages/graphql/execution/middleware.py", line 75, in make_it_promise
    return next(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/graphql_auth/bases.py", line 31, in mutate
    return cls.resolve_mutation(root, info, **input)
  File "/usr/local/lib/python3.8/site-packages/graphql_auth/mixins.py", line 157, in resolve_mutation
    UserStatus.verify(token)
  File "/usr/local/lib/python3.8/site-packages/graphql_auth/models.py", line 145, in verify
    user = UserModel._default_manager.get(**payload)
  File "/usr/local/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(
graphql.error.located_error.GraphQLLocatedError: ExtUser matching query does not exist.
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

No branches or pull requests

1 participant