fixed IP not updating, fixed usernames being case sensitive in update query

This commit is contained in:
Phillip Tarrant 2020-09-22 23:26:23 -04:00
parent 635bef867b
commit 6951d7cc8a
2 changed files with 7 additions and 5 deletions

View File

@ -176,7 +176,7 @@ class db_builder:
api_token = helper.random_string_generator(32) api_token = helper.random_string_generator(32)
Users.insert({ Users.insert({
Users.username: username, Users.username: username.lower(),
Users.password: helper.encode_pass(password), Users.password: helper.encode_pass(password),
Users.api_token: api_token, Users.api_token: api_token,
Users.enabled: True Users.enabled: True

View File

@ -95,10 +95,12 @@ class PublicHandler(BaseHandler):
logger.info("User: {} Logged in from IP: {}".format(user_data, self.get_remote_ip())) logger.info("User: {} Logged in from IP: {}".format(user_data, self.get_remote_ip()))
# record this login # record this login
Users.update({ q = Users.select().where(Users.username == entered_username.lower()).get()
Users.last_ip: self.get_remote_ip(), q.last_ip = self.get_remote_ip()
Users.last_login: helper.get_time_as_string() q.last_login = helper.get_time_as_string()
}).where(Users.username == entered_username).execute() q.save()
print(q)
# log this login # log this login
db_helper.add_to_audit_log(user_data.user_id, "Logged in", 0, self.get_remote_ip()) db_helper.add_to_audit_log(user_data.user_id, "Logged in", 0, self.get_remote_ip())