jazzband / django-axes

Keep track of failed login attempts in Django-powered sites.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AXES_LOCKOUT_PARAMETERS = ["username"] with email as username doesn't work

Zerotask opened this issue · comments

Describe the bug
We have a custom user model which uses an email field as username

USERNAME_FIELD = "email"

If I set

AXES_LOCKOUT_PARAMETERS = ["username"]
AXES_CLIENT_IP_CALLABLE = lambda x: None  # noqa: E731

and try to login, I get the console output:

AXES: Username is None and username is the only one lockout parameter, new record will NOT be created.

Expected behavior
email is used as the username

Your environment
python version: 3.12
django version: 4.2.7
django-axes version: 6.1.1
Operating system: MacOS 14.1

Additional context

Before I tried it with ipware which works perfectly.

Update: it does work, if I set AXES_USERNAME_FORM_FIELD = "email"
Is it possible to check for USERNAME_FIELD so that you don't have to additionally set this?

Sure, would you like to open a PR for implementing this improvement?