flavors / django-graphql-jwt

JSON Web Token (JWT) authentication for Graphene Django
https://django-graphql-jwt.domake.io
MIT License
820 stars 173 forks source link

User is disabled error #332

Open IliasVilux opened 7 months ago

IliasVilux commented 7 months ago

I use django with graphene and django-auth-ldap. When i run a query or mutation that has @login_required with https headers token i get this:

{
    "errors": [
        {
            "message": "User is disabled",
            "locations": [
                {
                    "line": 2,
                    "column": 2
                }
            ],
            "path": [
                "colaboradores"
            ]
        }
    ],
    "data": {
        "colaboradores": null
    }
}

settings.py

MIDDLEWARE = [
    ...
    "django.contrib.auth.middleware.AuthenticationMiddleware",
    ...
]

GRAPHENE = {
    "SCHEMA": "core.schema.schema",
    "MIDDLEWARE": [
        "graphql_jwt.middleware.JSONWebTokenMiddleware",
    ],
}

AUTHENTICATION_BACKENDS = [
    "graphql_jwt.backends.JSONWebTokenBackend",
    "django_auth_ldap.backend.LDAPBackend",
    "django.contrib.auth.backends.ModelBackend",
]

schema.py

class Mutation(
    mutationColaboradores,
    mutationEstaciones,
    mutationEstacionesColaboradores,
    graphene.Mutation,
):
    token_auth = graphql_jwt.ObtainJSONWebToken.Field()
    verify_token = graphql_jwt.Verify.Field()
    refresh_token = graphql_jwt.Refresh.Field()

    def mutate(self):
        return ""

schemaColaborador.py

class Query(graphene.ObjectType):
    colaboradores = graphene.List(ColaboradorType)

    @login_required
    def resolve_colaboradores(self, info):
        return Colaborador.objects.all()