code: def user_login_failed(
              self,
              sender,
              credentials: dict,
              request: AxesHttpRequest = None,
              **kwargs
      ):  # pylint: disable=too-many-locals
          
  
          if request is None:
              log.error('AXES: AxesCacheHandler.user_login_failed does not function without a request.')
              return
  
          username = get_client_username(request, credentials)
          client_str = get_client_str(username, request.axes_ip_address, request.axes_user_agent, request.axes_path_info)
  
          if self.is_whitelisted(request, credentials):
              log.info('AXES: Login failed from whitelisted client %s.', client_str)
              return
  
          failures_since_start = 1 + self.get_failures(request, credentials)
  
          if failures_since_start > 1:
              log.warning(
                  'AXES: Repeated login failure by %s. Count = %d of %d. Updating existing record in the cache.',
                  client_str,
                  failures_since_start,
                  settings.AXES_FAILURE_LIMIT,
              )
          else:
              log.warning(
                  'AXES: New login failure by %s. Creating new record in the cache.',
                  client_str,
              )
  
          cache_key = get_client_cache_key(request, credentials)
          self.cache.set(cache_key, failures_since_start, self.cache_timeout)
  
          if failures_since_start >= settings.AXES_FAILURE_LIMIT:
              log.warning('AXES: Locking out %s after repeated login failures.', client_str)
  
              user_locked_out.send(
                  'axes',
                  request=request,
                  username=username,
                  ip_address=request.axes_ip_address,
              )
  
              raise AxesSignalPermissionDenied('Locked out due to repeated login failures.')
docs: When user login fails, save attempt record in cache and lock user out if necessary.
  
          :raises AxesSignalPermissionDenied: if user should be locked out.