From: Giorgio Ravera Date: Wed, 11 Mar 2026 19:45:13 +0000 (+0100) Subject: Minor changes X-Git-Url: http://git.giorgioravera.it/?a=commitdiff_plain;h=0ab349d2e2a35bf44cbda2602d0ff705d3292e68;p=network-manager.git Minor changes --- diff --git a/backend/db/aliases.py b/backend/db/aliases.py index 2852ff4..3aa0878 100644 --- a/backend/db/aliases.py +++ b/backend/db/aliases.py @@ -168,5 +168,4 @@ def init_db_alias_table(cur): """) cur.execute("CREATE INDEX idx_aliases_name ON aliases(name);") - logger.info("ALIASES DB: Database initialized successfully for %s", settings.DOMAIN) - logger.info("ALIASES DB: Public IP: %s", settings.EXTERNAL_NAME) + logger.info("ALIASES DB: Database initialized successfully") diff --git a/backend/db/db.py b/backend/db/db.py index 608874b..99257fe 100644 --- a/backend/db/db.py +++ b/backend/db/db.py @@ -46,6 +46,5 @@ def init_db(): func(cur) conn.commit() - conn.close() logger.info("DB Initialization Completed") diff --git a/backend/db/hosts.py b/backend/db/hosts.py index eed87e9..ea9c1f0 100644 --- a/backend/db/hosts.py +++ b/backend/db/hosts.py @@ -229,5 +229,4 @@ def init_db_hosts_table(cur): """) cur.execute("CREATE INDEX idx_txt_host ON txt_records(host_id);") - logger.info("HOSTS DB: Database initialized successfully for %s", settings.DOMAIN) - logger.info("HOSTS DB: Public IP: %s", settings.EXTERNAL_NAME) + logger.info("HOSTS DB: Tables initialized successfully") diff --git a/backend/db/users.py b/backend/db/users.py index 111d870..ed5110f 100644 --- a/backend/db/users.py +++ b/backend/db/users.py @@ -31,6 +31,28 @@ def get_user_by_username(username): cur.execute("SELECT * FROM users WHERE username = ?", (username,)) return cur.fetchone() +# ----------------------------- +# Create User +# ----------------------------- +def create_user(username, password_hash, email=None, is_admin=0, modules=None): + conn = get_db() + cur = conn.cursor() + + cur.execute(""" + INSERT INTO users ( + username, password_hash, email, is_admin, modules, status, + created_at, updated_at, password_changed_at + ) VALUES (?, ?, ?, ?, ?, 'active', strftime('%s','now'), strftime('%s','now'), strftime('%s','now')); + """, ( + username, + password_hash, + email, + is_admin, + json.dumps(modules or []) + )) + + conn.commit() + # ----------------------------- # Create Users Table # ----------------------------- @@ -76,24 +98,4 @@ def init_db_users_table(cur): "active" )) -# ----------------------------- -# Create User -# ----------------------------- -def create_user(username, password_hash, email=None, is_admin=0, modules=None): - conn = get_db() - cur = conn.cursor() - - cur.execute(""" - INSERT INTO users ( - username, password_hash, email, is_admin, modules, status, - created_at, updated_at, password_changed_at - ) VALUES (?, ?, ?, ?, ?, 'active', strftime('%s','now'), strftime('%s','now'), strftime('%s','now')); - """, ( - username, - password_hash, - email, - is_admin, - json.dumps(modules or []) - )) - - conn.commit() + logger.info("USERS DB: Tables initialized successfully") \ No newline at end of file