Revision 672d445a snf-astakos-app/astakos/im/target/local.py

b/snf-astakos-app/astakos/im/target/local.py
42 42
from astakos.im.views import requires_anonymous
43 43
from astakos.im.models import AstakosUser
44 44
from astakos.im.forms import LoginForm
45
from astakos.im.settings import RATELIMIT_RETRIES_ALLOWED
46

  
47
from ratelimit.decorators import ratelimit
48

  
49
retries = RATELIMIT_RETRIES_ALLOWED-1
50
rate = str(retries)+'/m'
45 51

  
46 52
@requires_anonymous
53
@ratelimit(field='username', method='POST', rate=rate)
47 54
def login(request, on_failure='im/login.html'):
48 55
    """
49 56
    on_failure: the template name to render on login failure
50 57
    """
51
    form = LoginForm(data=request.POST)
58
    was_limited = getattr(request, 'limited', False)
59
    form = LoginForm(data=request.POST, was_limited=was_limited, request=request)
52 60
    next = request.POST.get('next')
53 61
    if not form.is_valid():
54 62
        return render_to_response(on_failure,

Also available in: Unified diff