hotfix
This commit is contained in:
+15
-4
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user