fix: password auth error

This commit is contained in:
Terry Geng 2020-05-27 08:52:27 +08:00
parent a195a8afaf
commit 3330017586
No known key found for this signature in database
GPG Key ID: F982F8EA1DF720E7
2 changed files with 6 additions and 4 deletions

View File

@ -71,7 +71,7 @@ def register_all_commands(bot):
bot.register_command(constants.commands('add_webinterface_user'), cmd_web_user_add, admin=True)
bot.register_command(constants.commands('remove_webinterface_user'), cmd_web_user_remove, admin=True)
bot.register_command(constants.commands('list_webinterface_user'), cmd_web_user_list, admin=True)
bot.register_command(constants.commands('change_user_password'), cmd_user_password)
bot.register_command(constants.commands('change_user_password'), cmd_user_password, no_partial_match=True)
# Just for debug use
bot.register_command('rtrms', cmd_real_time_rms, True)
#bot.register_command('loop', cmd_loop_state, True)

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: