Exemplo n.º 1
0
    def process_exception(self, request, exception):  # pylint: disable=inconsistent-return-statements
        """
        Exception handler that processes exceptions raised by the axes signal handler when request fails with login.

        Refer to axes.signals.log_user_login_failed for the error code.

        :param request: HTTPRequest that will be locked out.
        :param exception: Exception raised by Django views or signals. Only AxesSignalPermissionDenied will be handled.
        :return: HTTPResponse that indicates the lockout or None.
        """

        if isinstance(exception, AxesSignalPermissionDenied):
            return get_lockout_response(request)
Exemplo n.º 2
0
    def process_exception(self, request, exception):  # pylint: disable=inconsistent-return-statements
        """
        Exception handler that processes exceptions raised by the axes signal handler when request fails with login.

        Refer to axes.signals.log_user_login_failed for the error code.

        :param request: HTTPRequest that will be locked out.
        :param exception: Exception raised by Django views or signals. Only AxesSignalPermissionDenied will be handled.
        :return: HTTPResponse that indicates the lockout or None.
        """

        if isinstance(exception, AxesSignalPermissionDenied):
            return get_lockout_response(request)
Exemplo n.º 3
0
    def inner(request, *args, **kwargs):
        if is_already_locked(request):
            return get_lockout_response(request)

        return func(request, *args, **kwargs)
Exemplo n.º 4
0
 def test_get_lockout_response_lockout_response(self):
     response = get_lockout_response(request=self.request)
     self.assertEqual(type(response), HttpResponse)
Exemplo n.º 5
0
 def test_get_lockout_response_lockout_json(self):
     self.request.is_ajax = lambda: True
     response = get_lockout_response(request=self.request)
     self.assertEqual(type(response), JsonResponse)
Exemplo n.º 6
0
 def test_get_lockout_response_lockout_template(self, render):
     self.assertFalse(render.called)
     get_lockout_response(request=self.request)
     self.assertTrue(render.called)
Exemplo n.º 7
0
 def test_get_lockout_response_cool_off(self):
     get_lockout_response(request=self.request)
Exemplo n.º 8
0
 def test_get_lockout_response_lockout_response(self):
     response = get_lockout_response(request=self.request)
     self.assertEqual(type(response), HttpResponse)
Exemplo n.º 9
0
 def test_get_lockout_response_lockout_json(self):
     self.request.is_ajax = lambda: True
     response = get_lockout_response(request=self.request)
     self.assertEqual(type(response), JsonResponse)
Exemplo n.º 10
0
 def test_get_lockout_response_lockout_template(self, render):
     self.assertFalse(render.called)
     get_lockout_response(request=self.request)
     self.assertTrue(render.called)
Exemplo n.º 11
0
 def test_get_lockout_response_cool_off(self):
     get_lockout_response(request=self.request)