Skip to content

BUG: Setting AXES_USERNAME_FORM_FIELD to a custom value fails to fill the username field for AccessAttempt #1159

@jur-clerkx

Description

@jur-clerkx

Describe the bug
In our project, we have set the AXES_USERNAME_FORM_FIELD to a custom value. When doing this, AccessAttempt in the database doesn't get a username set, this stays None.

After a quick debug, it showed that there is a call being made where the credentials are given. However, in the credentials dict, the username is stored in a field named username in stead of the value set in AXES_USERNAME_FORM_FIELD. Since the code tries to fetch the username based on the name in the settings, this will return None. Assumption for now is that this were it goes wrong.

To Reproduce
Steps to reproduce the behavior:

  1. Create a custom login form with a username field that has a custom name (e.g. auth-username)
  2. Set the AXES_USERNAME_FORM_FIELD to auth-username
  3. Do a failed login attempt
  4. The username field on the AccessAttempt will be empty.

Expected behavior
The username field on the AccessAttempt model is filled with the correct username.

Your environment
python version: 3.8.18
django version: 3.2.23
django-axes version: 6.3.0
Operating system: Mac OS

Additional context
What was interesting was that the credentials that were shown in the debugger was:
username: username filled in the form
password: ***********************

Possibly this conflicts with the logging implementation.

Possible implementation
Probably an easy bugfix where username is used in stead of the value set in AXES_USERNAME_FORM_FIELD

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions