Open
Description
django-rest-framework/rest_framework/authtoken/models.py
Lines 9 to 37 in 5ad467a
The sample space is large 2 ** (8 * 20)
, but the probability is not 0 that generate_key
returns a key that already exists, and then the save would update the existing one.
The smallest change, turns this into an integrity error:
def save(self, *args, **kwargs):
if not self.key:
self.key = self.generate_key()
kwargs["force_insert"] = True
return super().save(*args, **kwargs)
Metadata
Metadata
Assignees
Labels
No labels