flavors / django-graphql-jwt

JSON Web Token (JWT) authentication for Graphene Django

Home Page:https://django-graphql-jwt.domake.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

check some conditions before login

MD147MD opened this issue · comments

hi dear developers, actually in my project i need to check some conditions before return token to user in token_auth mutation
like this :
if not user.is_blocked:
# return Token
somthing like this
what should i do ? :)

You could subclass the mutation and add your own logic to the resolver. I.e. something like this:

from graphql_jwt import JSONWebTokenMutation

class ObtainJSONWebToken(JSONWebTokenMutation):

    @classmethod
    def resolve(cls, root, info, **kwargs):
        if not info.context.user.is_active:
            raise PermissionDenied("Permission denied")

        return cls()

thank you bro ❤️