django-graphql-jwt
django-graphql-jwt copied to clipboard
revoke_refresh_token not firing
Hi, I am trying to implement one-time use refresh token, I created the signal as the documentation stated but it's firing:
from django.dispatch import receiver
from graphql_jwt.refresh_token.signals import refresh_token_rotated
@receiver(refresh_token_rotated, sender=RefreshToken)
def revoke_refresh_token(sender, request, refresh_token, **kwargs):
refresh_token.revoke(refresh_token)
print("Please work this time")
whenever I generate a new refresh_token using a previous refresh_token nothing happens.
A am tried too, it is not working
Any updates on this?
Is it because the sender is the RefreshTokenMixin
rather than the RefreshToken
model? Looking at this line here https://github.com/flavors/django-graphql-jwt/blob/704f24e7ebbea0b81015ef3c1f4a302e9d432ecf/graphql_jwt/refresh_token/mixins.py#L57
the sender is cls
not the model itself.
Which means to fix it just remove the sender
from the signal receiver call, as per Django docs specifying that sender would only filter the signals out to your disadvantage in this case.
@receiver(refresh_token_rotated)
def revoke_refresh_token(sender, request, refresh_token, **kwargs):
refresh_token.revoke(refresh_token)
print("This should work now")