refactor database class

This commit is contained in:
WorldTeacher
2024-01-31 14:17:30 +01:00
parent 155958e187
commit 6fa71edc2d
3 changed files with 403 additions and 712 deletions

View File

@@ -24,21 +24,21 @@ class AdminCommands:
def create_admin(self):
salt = self.create_salt()
hashed_password = self.hash_password("admin")
self.db.create_user("admin", salt+hashed_password, "admin", salt)
self.db.createUser("admin", salt+hashed_password, "admin", salt)
def hash_password(self, password):
hashed = hashlib.sha256((password).encode("utf-8")).hexdigest()
return hashed
def list_users(self):
return self.db.get_users()
return self.db.getUsers()
def delete_user(self, username):
self.db.delete_user(username)
self.db.deleteUser(username)
def change_password(self, username, password):
hashed_password = self.hash_password(password)
self.db.change_password(username, hashed_password)
self.db.changePassword(username, hashed_password)
if __name__ == "__main__":