From 4df7858da6c505a75e0890fe9516f64480325ea0 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Wed, 21 Feb 2024 00:04:07 -0500 Subject: [PATCH] Fix code quality issues --- app/classes/web/public_handler.py | 52 +++++++++++++++---------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/app/classes/web/public_handler.py b/app/classes/web/public_handler.py index 3f46780f..467765ea 100644 --- a/app/classes/web/public_handler.py +++ b/app/classes/web/public_handler.py @@ -1,7 +1,4 @@ import logging -import binascii -import base64 -import urllib import json import nh3 from jsonschema import validate @@ -237,30 +234,31 @@ class PublicHandler(BaseHandler): return self.finish_json( 200, {"status": "ok", "data": {"message": "login successful!"}} ) - else: - auth_log.error( - f"User attempted to log into {entered_username}." - f" Authentication failed from remote IP {self.get_remote_ip()}" - ) - self.controller.log_attempt(self.get_remote_ip(), entered_username) - # self.clear_cookie("user") - # self.clear_cookie("user_data") - self.clear_cookie("token") - error_msg = self.helper.translation.translate( - "login", "incorrect", self.helper.get_setting("language") - ) - if entered_password == "app/config/default-creds.txt": - error_msg += ". " - error_msg += self.helper.translation.translate( - "login", "defaultPath", self.helper.get_setting("language") - ) - # log this failed login attempt - self.controller.management.add_to_audit_log( - user_data.user_id, "Tried to log in", 0, self.get_remote_ip() - ) - return self.finish_json( - 403, - {"status": "error", "error": error_msg}, + + # We'll continue on and handle unsuccessful logins + auth_log.error( + f"User attempted to log into {entered_username}." + f" Authentication failed from remote IP {self.get_remote_ip()}" + ) + self.controller.log_attempt(self.get_remote_ip(), entered_username) + # self.clear_cookie("user") + # self.clear_cookie("user_data") + self.clear_cookie("token") + error_msg = self.helper.translation.translate( + "login", "incorrect", self.helper.get_setting("language") + ) + if entered_password == "app/config/default-creds.txt": + error_msg += ". " + error_msg += self.helper.translation.translate( + "login", "defaultPath", self.helper.get_setting("language") ) + # log this failed login attempt + self.controller.management.add_to_audit_log( + user_data.user_id, "Tried to log in", 0, self.get_remote_ip() + ) + return self.finish_json( + 403, + {"status": "error", "error": error_msg}, + ) else: self.redirect("/login?")