This commit is contained in:
2026-08-24 23:11:35 +02:00
parent 42fe8d9a76
commit ecc110641b
5 changed files with 32 additions and 13 deletions
+15 -4
View File
@@ -26,13 +26,22 @@ def init_db(path: str) -> None:
USERNAME TEXT NOT NULL UNIQUE,
PWHASH TEXT NOT NULL,
PWSALT TEXT NOT NULL,
EMAIL TEXT
EMAIL TEXT,
IS_ADMIN INTEGER NOT NULL DEFAULT 0
)
''')
connection.commit()
cursor.close()
cursor.execute('''
SELECT COUNT(*) FROM Users
''')
if cursor.fetchone()[0] == 0:
username = "root"
password = urandom(8).hex()
create_user(path, username, password, is_admin=True)
print(f"No users detected, created new admin\nUser: {username}\nPass: {password}", flush=True)
def check_token_domain(db_path: str, token: str, domain: str) -> bool:
with sqlite3.connect(db_path) as connection:
@@ -287,7 +296,9 @@ def create_user(db_path: str, username: str, password: str, domains: list = [],
cursor = connection.cursor()
username.strip()
email.strip()
if email is not None:
email.strip()
cursor.execute('''
SELECT COUNT(*) FROM Users