django-mfa2
django-mfa2 copied to clipboard
Using user foreign key to settings.AUTH_USER_MODEL instead of "username" in User_Keys
Currently the User_Keys model in models.py, uses username=models.CharField(max_length = 50)
.
This could be problematic in case the django app allows for changing the username
for example. Also deleting a user will not result in deleting entries for that user in the User_Keys model in the database.
The mainstream approach is to use:
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
The request
in django view functions already have request.user
variable that can be used directly when CRUD an entry in the User_Keys table.
Nonetheless, changing the data model will require a lot of refactoring.