From a45c314bab7490a9f9e0765c85ef3bdfe204e639 Mon Sep 17 00:00:00 2001 From: spekulaas Date: Sat, 11 Nov 2023 08:57:29 +0100 Subject: [PATCH] user settings fixes --- goodchain/src/classes/User.py | 18 ++++++------------ goodchain/src/helpers/DatabaseHelper.py | 2 ++ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/goodchain/src/classes/User.py b/goodchain/src/classes/User.py index d4ca9e8..4736b1c 100644 --- a/goodchain/src/classes/User.py +++ b/goodchain/src/classes/User.py @@ -74,9 +74,7 @@ class User: hashed_new_password = UtilityHelper.computeHash(new_password) hashed_old_password = UtilityHelper.computeHash(old_password) - private_key_bytes = Signature.privateKeyToBytes(self.private_ser) - - if self.db.changePassword(private_key_bytes, hashed_old_password, hashed_new_password) == True: + if self.db.changePassword(self.private_ser, hashed_old_password, hashed_new_password) == True: print('Password updated') else: print('Something went wrong while trying to update password..') @@ -90,9 +88,8 @@ class User: print("Username already taken") return False - private_key_bytes = Signature.privateKeyToBytes(self.private_ser) - - if self.db.changeUsername(private_key_bytes, new_username) == True: + if self.db.changeUsername(self.private_ser, new_username) == True: + self.username = new_username print('Username updated') else: print('Something went wrong while trying to update username..') @@ -113,9 +110,7 @@ class User: else: print('Invalid input') - private_key_bytes = Signature.privateKeyToBytes(self.private_ser) - - if self.db.deleteUser(private_key_bytes) == True: + if self.db.deleteUser(self.private_ser) == True: print('Account deleted') self.logout() return True @@ -124,9 +119,8 @@ class User: return False def printAccountInfo(self): - private_ser, public_ser = Signature.keysToBytes(self.private_ser, self.public_ser) print('Username: ' + self.username) - print(public_ser) - print(private_ser) + print(self.public_ser) + print(self.private_ser) diff --git a/goodchain/src/helpers/DatabaseHelper.py b/goodchain/src/helpers/DatabaseHelper.py index b3885f2..8e61519 100644 --- a/goodchain/src/helpers/DatabaseHelper.py +++ b/goodchain/src/helpers/DatabaseHelper.py @@ -69,6 +69,8 @@ class DatabaseHelper: try: self.cursor.execute("UPDATE `users` SET `password` = ? WHERE (`private_key` = ? AND `password` = ?)", (password, user_privatekey, old_password,)) self.commit() + if self.cursor.rowcount < 1: + return False return True