Skip to content

Commit ca3fe29

Browse files
committed
small bug fix
1 parent fbb70ba commit ca3fe29

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Modules/DatabaseWrapper.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
import sqlite3
33
from Modules.Encryption import DatabaseEncrypt
4+
45
logging.basicConfig(format=' %(asctime)s - %(message)s', level=logging.WARNING)
56

67

@@ -29,7 +30,8 @@ def add_user(self, username, password):
2930
if user is not None:
3031
logging.info("User already exists, aborting..")
3132
return 'ERROR'
32-
self.cursor.execute('insert into users (USER_NAME,PASSWORD) values (?,?);', (username,self.db_encrypt.encrypt(password)))
33+
self.cursor.execute('insert into users (USER_NAME,PASSWORD) values (?,?);',
34+
(username, self.db_encrypt.encrypt(password)))
3335
self.db_conn.commit()
3436
return 'SUCCESS'
3537

@@ -39,7 +41,7 @@ def edit_user(self, username, password, new_username, new_password):
3941
logging.info("Can't find the requested user, aborting..")
4042
return 'ERROR'
4143
self.cursor.execute("update users set USER_NAME=?,PASSWORD=? where ID is ?;",
42-
(new_username, new_password, user[0]))
44+
(new_username, self.db_encrypt.encrypt(new_password), user[0]))
4345
self.db_conn.commit()
4446
return 'SUCCESS'
4547

@@ -56,9 +58,11 @@ def delete_user(self, user_id):
5658
return 'SUCCESS'
5759

5860
def get_user(self, username, password):
59-
self.cursor.execute('select * from users where USER_NAME is ? and PASSWORD is ?;', (username, password))
60-
user = self.cursor.fetchone()
61-
return user
61+
users = self.get_users()
62+
for user in users:
63+
if user[1] == username and self.db_encrypt.decrypt(user[2]) == password:
64+
return user
65+
return None
6266

6367
def get_user_by_id(self, user_id):
6468
self.cursor.execute('select * from users where ID is ?;', (user_id,))

Modules/TaskExecuteThread.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ def run(self):
8686
task.set_status('completed')
8787
self.task_completed_signal.emit(task.get_task_name())
8888
self.bot.logout()
89+
else:
90+
print(f'Task executor failed to login to account with email: {task.get_user_name()}')
8991
if 15 > self.waiting_time > 0:
9092
self.sleep(int(self.waiting_time))
9193
else:

0 commit comments

Comments
 (0)