From add784df4238fb45422c5482273d47e10eb85db8 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 12 Apr 2022 18:33:00 -0400 Subject: [PATCH] Fix stack when username is wrong. --- app/classes/web/public_handler.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/classes/web/public_handler.py b/app/classes/web/public_handler.py index 72185279..5269ba2e 100644 --- a/app/classes/web/public_handler.py +++ b/app/classes/web/public_handler.py @@ -102,8 +102,21 @@ class PublicHandler(BaseHandler): entered_password = bleach.clean(self.get_argument("password")) # pylint: disable=no-member - user_id = helper_users.get_user_id_by_name(entered_username.lower()) - user_data = helper_users.get_user_model(user_id) + try: + user_id = helper_users.get_user_id_by_name(entered_username.lower()) + user_data = helper_users.get_user_model(user_id) + except: + error_msg = "Incorrect username or password. Please try again." + # self.clear_cookie("user") + # self.clear_cookie("user_data") + self.clear_cookie("token") + if self.request.query: + self.redirect( + f"/public/login?error_msg={error_msg}&{self.request.query}" + ) + else: + self.redirect(f"/public/login?error_msg={error_msg}") + return # if we don't have a user if not user_data: