Skip to content

invalidate_previous_tokens should be post_save to avoid infinite recursion #30

@lee-hodg

Description

@lee-hodg

In https://github.com/aaronn/django-rest-framework-passwordless/blob/master/drfpasswordless/signals.py#L13 your doc string says post_save, which I believe is a correct implementation, but the actual code uses pre_save.

With pre_save I am seeing infinite loops whenever the user has more than 1 active tokens already. The pre_save calls save, which in turn invokes pre_save, but active_tokens = CallbackToken.objects.active().filter(user=instance.user).exclude(id=instance.id) grabs the same tokens from the database (as we are pre-save so the is_active=False hasn't yet been comitted). This once again invokes another save->pre_save->save until maximum recursion limit is hit....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions