user settings fixes

This commit is contained in:
Ryan Bakkes 2023-11-11 08:57:29 +01:00
parent e65e19e293
commit a45c314bab
2 changed files with 8 additions and 12 deletions

View File

@ -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)

View File

@ -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