Skip to content

OutstandingToken user should be nullified with SET_NULL#267

Open
Andrew-Chen-Wang wants to merge 3 commits intojazzband:masterfrom
Andrew-Chen-Wang:patch-2
Open

OutstandingToken user should be nullified with SET_NULL#267
Andrew-Chen-Wang wants to merge 3 commits intojazzband:masterfrom
Andrew-Chen-Wang:patch-2

Conversation

@Andrew-Chen-Wang
Copy link
Member

@Andrew-Chen-Wang Andrew-Chen-Wang commented Jul 7, 2020

Fixes #266 #232 #201

Originally, in the model of OutstandingToken, you can see that the user attribute is supposed to be null if the user is deleted. If it remained on_delete=models.CASCADE then there would be no point in null=True and blank=True. I think the implementation was just unintended behavior, so the cascading on user deletion should set the OutstandingToken's user to null.

@Andrew-Chen-Wang
Copy link
Member Author

Andrew-Chen-Wang commented Jul 7, 2020

Duplicate #237

The setup is different. For one, #237 really didn't update post-review. Secondly, perhaps allowing the deletion of OutstandingToken still shouldn't happen. Instead, if the functionality should remain the same: read-only, no deleting OustandingToken.

Soooo hence this PR.

@Andrew-Chen-Wang
Copy link
Member Author

Andrew-Chen-Wang commented Jul 11, 2020

TODO Should use a new migration file or else upgraders will not get the changes. i.e. not ready

model_name='outstandingtoken',
name='user',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in a separate file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't delete users if using token blacklist app

1 participant