I allow my users to change their usernames so I need to update their tokens after that action.
I have a custom refresh serializer:
class CustomRefreshJSONWebTokenSerializer(RefreshJSONWebTokenSerializer):
"""Checks user using user_id instead of username"""
def _check_user(self, payload):
user_id = api_settings.JWT_PAYLOAD_GET_USER_ID_HANDLER(payload)
if not user_id:
msg = _('Invalid payload.')
raise serializers.ValidationError(msg)
# Make sure user exists
try:
user = get_user_model().objects.get(pk=user_id)
except get_user_model().DoesNotExist:
msg = _("User doesn't exist.")
raise serializers.ValidationError(msg)
if not user.is_active:
msg = _('User account is disabled.')
print('Disabled')
raise serializers.ValidationError(msg)
return user
When I try to refresh token after username change I receive "Invalid signature."
Is it possible to refresh token after username change?
I allow my users to change their usernames so I need to update their tokens after that action. I have a custom refresh serializer:
When I try to refresh token after username change I receive "Invalid signature."
Is it possible to refresh token after username change?