From 61f4d8bb38ab7c6c6793ff99b0cc9f4c6a22e18c Mon Sep 17 00:00:00 2001 From: zhengxie Date: Mon, 7 Jul 2014 14:14:18 +0800 Subject: [PATCH] [auth] Enlarge login attempt limit, and fix login attempts bug --- seahub/auth/views.py | 5 +++-- seahub/settings.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/seahub/auth/views.py b/seahub/auth/views.py index cfbb579017..cb3695f12d 100644 --- a/seahub/auth/views.py +++ b/seahub/auth/views.py @@ -84,18 +84,19 @@ def _incr_login_faied_attempts(username=None, ip=None): Returns new value of failed attempts. """ timeout = settings.LOGIN_ATTEMPT_TIMEOUT + username_attempts = 0 + ip_attempts = 0 + if username: try: username_attempts = cache.incr(LOGIN_ATTEMPT_PREFIX + username) except ValueError: - username_attempts = 0 cache.set(LOGIN_ATTEMPT_PREFIX + username, 0, timeout) if ip: try: ip_attempts = cache.incr(LOGIN_ATTEMPT_PREFIX + ip) except ValueError: - ip_attempts = 0 cache.set(LOGIN_ATTEMPT_PREFIX + ip, 0, timeout) return max(username_attempts, ip_attempts) diff --git a/seahub/settings.py b/seahub/settings.py index c5276a25e6..b3192c0b27 100644 --- a/seahub/settings.py +++ b/seahub/settings.py @@ -375,7 +375,7 @@ LOGGING = { } #Login Attempt -LOGIN_ATTEMPT_LIMIT = 3 +LOGIN_ATTEMPT_LIMIT = 10 LOGIN_ATTEMPT_TIMEOUT = 15 * 60 # in seconds (default: 15 minutes) # Age of cookie, in seconds (default: 1 day).