Skip to content

user_locked_out signal always returns username of None #1043

@Neumsy

Description

@Neumsy

We are using Django 3.2.18 and AXES 5.30.0 on Python 3.6. We are not utilizing DRF for our implementation.

When we attempt to catch the "user_locked_out" signal sent by axes, the username being returned is always set to None.

@receiver(user_locked_out)
def log_user_lockout(request, username, ip_address, **kwargs):
    """Log user lockout using axes signal."""
    user = username # This will always result in None
    function_signal.send("audit_log", message=f"{user} account has been locked.")`

Is there a method or way to trigger a locked out user account without using the DRF? My current workaround is to trigger on the user_login_failed signal and inspect the kwargs.get("request").axes_locked_out value. I still need to have the user_locked_out code in order to properly trigger the signal.

End goal of the code is we want to log when a user is locked out to an audit log file with the username of the account that was locked out.

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