Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback token key changes after invalidating it. (after every update actually) #75

Merged
merged 1 commit into from
Nov 17, 2020

Conversation

thetarby
Copy link
Contributor

Because of the pre_save signal which checks whether a token with the same key already exists and recreates key if that is the case, after each save call on a callback token its key value changes. That is not good because even after invalidating a token its key value could be useful and also it requires an unnecessary db hit which is bad for performance.

To solve the problem, in pre_save handler first check if save is called to update an already existing token or it is called to create a new one. If it is called to update it then don't check for key's uniqueness.

@gozdecoban
Copy link

Hi Aaron, do you consider merging this? I have the same issue.

@aaronn
Copy link
Owner

aaronn commented Nov 16, 2020

Okay, I'll look into this this week.

@aaronn
Copy link
Owner

aaronn commented Nov 17, 2020

I think we actually need a migration for this too:

unique_together = (('key', 'is_active'),)

Because of this bit, any older keys with is_active=False will collide.

Edit: Actually I suppose this migration can be done separately.

@aaronn aaronn merged commit 92faffb into aaronn:master Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants