Merge pull request #27 from kencochrane/bug-fix-josh

fixing an issue @jlhawn found, we should only block if we are over the l...
This commit is contained in:
Ken Cochrane 2015-01-30 19:46:58 -05:00
commit 8ee8f3cd7b

View file

@ -185,12 +185,17 @@ def record_failed_attempt(ip, username):
ip_count = increment_key(get_ip_attempt_cache_key(ip))
user_count = increment_key(get_username_attempt_cache_key(username))
ip_block = False
user_block = False
# if either are over the limit, add to block
if ip_count > config.FAILURE_LIMIT or user_count > config.FAILURE_LIMIT:
if ip_count > config.FAILURE_LIMIT:
block_ip(ip)
ip_block = True
if user_count > config.FAILURE_LIMIT:
block_username(username)
return False
return True
user_block = True
# if any blocks return False, no blocks return True
return not (ip_block or user_block)
def unblock_ip(ip, pipe=None):