mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 23:20:51 +00:00
[auth] Enlarge login attempt limit, and fix login attempts bug
This commit is contained in:
@@ -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)
|
||||
|
@@ -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).
|
||||
|
Reference in New Issue
Block a user