From 6951d7cc8a9ef3107dc516cee4383bcf30c8d812 Mon Sep 17 00:00:00 2001 From: Phillip Tarrant Date: Tue, 22 Sep 2020 23:26:23 -0400 Subject: [PATCH] fixed IP not updating, fixed usernames being case sensitive in update query --- app/classes/shared/models.py | 2 +- app/classes/web/public_handler.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/classes/shared/models.py b/app/classes/shared/models.py index 33a12b98..a74bc7af 100644 --- a/app/classes/shared/models.py +++ b/app/classes/shared/models.py @@ -176,7 +176,7 @@ class db_builder: api_token = helper.random_string_generator(32) Users.insert({ - Users.username: username, + Users.username: username.lower(), Users.password: helper.encode_pass(password), Users.api_token: api_token, Users.enabled: True diff --git a/app/classes/web/public_handler.py b/app/classes/web/public_handler.py index 14320121..7ad975db 100644 --- a/app/classes/web/public_handler.py +++ b/app/classes/web/public_handler.py @@ -95,10 +95,12 @@ class PublicHandler(BaseHandler): logger.info("User: {} Logged in from IP: {}".format(user_data, self.get_remote_ip())) # record this login - Users.update({ - Users.last_ip: self.get_remote_ip(), - Users.last_login: helper.get_time_as_string() - }).where(Users.username == entered_username).execute() + q = Users.select().where(Users.username == entered_username.lower()).get() + q.last_ip = self.get_remote_ip() + q.last_login = helper.get_time_as_string() + q.save() + + print(q) # log this login db_helper.add_to_audit_log(user_data.user_id, "Logged in", 0, self.get_remote_ip())