You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In backend.py, in the "user_pre_save" receiver, the call to get the user's username is hard-coded to be a field called "username":
LoginAttemptLogger().reset(user.username)
This hard-coded assumption that all user models will have a username field is incorrect - the field is not guaranteed to exist when using a custom user models. For example, I'm implementing a customer user model that uses email address as it's unique key/surrogate username. The above line of code breaks when set "is_active" to True on a user in the Django admin and then saving their record.
I believe that line should be updated to use the "get_username" method that should exist on the user object (assuming the custom user model is set up correctly and is based on Django's AbstractBaseUser).
LoginAttemptLogger().reset(user.get_username())
As a workaround in the meantime, I've added a property to my custom user model that returns the value of "get_username" when "username" is referenced.
The text was updated successfully, but these errors were encountered:
django-useraudit/useraudit/backend.py
Line 29 in dea9967
In backend.py, in the "user_pre_save" receiver, the call to get the user's username is hard-coded to be a field called "username":
LoginAttemptLogger().reset(user.username)
This hard-coded assumption that all user models will have a username field is incorrect - the field is not guaranteed to exist when using a custom user models. For example, I'm implementing a customer user model that uses email address as it's unique key/surrogate username. The above line of code breaks when set "is_active" to True on a user in the Django admin and then saving their record.
I believe that line should be updated to use the "get_username" method that should exist on the user object (assuming the custom user model is set up correctly and is based on Django's AbstractBaseUser).
LoginAttemptLogger().reset(user.get_username())
As a workaround in the meantime, I've added a property to my custom user model that returns the value of "get_username" when "username" is referenced.
The text was updated successfully, but these errors were encountered: