fix: password auth error

This commit is contained in:
Terry Geng
2020-05-27 08:52:27 +08:00
parent a195a8afaf
commit 3330017586
2 changed files with 6 additions and 4 deletions

View File

@@ -120,9 +120,9 @@ def requires_auth(f):
if auth_method == 'password':
auth = request.authorization
user = auth.username
if not auth or not check_auth(auth.username, auth.password):
if auth:
if auth:
user = auth.username
if not check_auth(auth.username, auth.password):
if request.remote_addr in bad_access_count:
bad_access_count[request.remote_addr] += 1
log.info(f"web: failed login attempt, user: {auth.username}, from ip {request.remote_addr}."
@@ -134,6 +134,8 @@ def requires_auth(f):
else:
bad_access_count[request.remote_addr] = 1
log.info(f"web: failed login attempt, user: {auth.username}, from ip {request.remote_addr}.")
return authenticate()
else:
return authenticate()
if auth_method == 'token':
if 'user' in session and 'token' not in request.args: