Black codebase

This commit is contained in:
amcmanu3 2024-02-19 12:03:02 -05:00
parent f6bb6eafcd
commit 166e3c5088

View File

@ -1,7 +1,7 @@
import logging import logging
import nh3
import base64
import binascii import binascii
import base64
import nh3
from app.classes.shared.helpers import Helpers from app.classes.shared.helpers import Helpers
from app.classes.models.users import HelperUsers from app.classes.models.users import HelperUsers
@ -114,13 +114,18 @@ class PublicHandler(BaseHandler):
if self.request.query: if self.request.query:
next_page = "/login?" + self.request.query next_page = "/login?" + self.request.query
entered_username = nh3.clean(self.get_argument("username")) # pylint: disable=no-member entered_username = nh3.clean(
self.get_argument("username")
) # pylint: disable=no-member
try: try:
entered_password = base64.b64decode( entered_password = base64.b64decode(
self.get_argument("encPassword")).decode("utf-8") self.get_argument("encPassword")
).decode("utf-8")
except binascii.Error: except binascii.Error:
error_msg = ("Hello? Hello? Anybody home?" error_msg = (
" Go straight to jail. Do not pass go.") "Hello? Hello? Anybody home?"
" Go straight to jail. Do not pass go."
)
return self.redirect(f"/login?error_msg={error_msg}") return self.redirect(f"/login?error_msg={error_msg}")
try: try:
@ -138,8 +143,9 @@ class PublicHandler(BaseHandler):
# self.clear_cookie("user_data") # self.clear_cookie("user_data")
self.clear_cookie("token") self.clear_cookie("token")
if self.request.query: if self.request.query:
self.redirect(f"/login?err or_msg={error_msg}" self.redirect(
f"&{self.request.query}") f"/login?err or_msg={error_msg}" f"&{self.request.query}"
)
else: else:
self.redirect(f"/login?error_msg={error_msg}") self.redirect(f"/login?error_msg={error_msg}")
return return
@ -221,17 +227,13 @@ class PublicHandler(BaseHandler):
# self.clear_cookie("user") # self.clear_cookie("user")
# self.clear_cookie("user_data") # self.clear_cookie("user_data")
self.clear_cookie("token") self.clear_cookie("token")
error_msg = ( error_msg = self.helper.translation.translate(
self.helper.translation.translate("login", "login", "incorrect", self.helper.get_setting("language")
"incorrect",
self.helper.get_setting("language"))
) )
if entered_password == "app/config/default-creds.txt": if entered_password == "app/config/default-creds.txt":
error_msg += ". " error_msg += ". "
error_msg += ( error_msg += self.helper.translation.translate(
self.helper.translation.translate("login", "login", "defaultPath", self.helper.get_setting("language")
"defaultPath",
self.helper.get_setting("language"))
) )
# log this failed login attempt # log this failed login attempt
self.controller.management.add_to_audit_log( self.controller.management.add_to_audit_log(