change username

This commit is contained in:
Spekulaas
2023-10-25 22:13:34 +02:00
parent c14a360418
commit 359b1d8af1
3 changed files with 51 additions and 2 deletions

View File

@@ -53,7 +53,7 @@ class DatabaseHelper:
def createUser(self, private_key, public_key, username, password):
if not self.conn:
return False
return None
try:
self.cursor.execute("INSERT INTO `users` (private_key, public_key, username, password) VALUES (?, ?, ?, ?)", (private_key, public_key, username, password,))
self.commit()
@@ -76,6 +76,37 @@ class DatabaseHelper:
print(error)
return None
def changeUsername(self, user_privatekey, username):
if not self.conn:
return None
# Execute the query
try:
self.cursor.execute("UPDATE `users` SET username = ? WHERE `private_key` = ?", (username, user_privatekey,))
self.commit()
return True
except sqlite3.Error as error:
print(error)
return None
def deleteUser(self, user_privatekey):
# Check if the database is open
if not self.conn:
return None
# Execute the query
try:
self.cursor.execute("DELETE FROM `users` WHERE `private_key` = ?", (user_privatekey, ))
self.commit()
return True
except sqlite3.Error as error:
print(error)
return None
def fetchUserByUsername(self, username):
if not self.conn:
return None

View File

@@ -164,7 +164,7 @@ class MenuHelper:
print(user.private_key)
case "Change username":
print("TODO")
user.updateAccount()
case "Change password":
user.updatePassword()