read log files from end, added user management

This commit is contained in:
2026-06-04 13:21:56 -04:00
parent 8a11acfcfd
commit 0796982fd7
8 changed files with 471 additions and 66 deletions
+37
View File
@@ -452,6 +452,43 @@ def create_user(username, password_hash, role="viewer", is_active=1):
return cursor.lastrowid
def update_user_password(user_id, password_hash):
with _tx():
cursor = _conn.execute(
"""
UPDATE users
SET password_hash = ?
WHERE id = ?
""",
(password_hash, user_id),
)
return cursor.rowcount
def delete_user(user_id):
with _tx():
cursor = _conn.execute(
"""
DELETE FROM users
WHERE id = ?
""",
(user_id,),
)
return cursor.rowcount
def count_admin_users():
with _lock:
row = _conn.execute(
"""
SELECT COUNT(*) AS n
FROM users
WHERE role = 'admin' AND is_active = 1
"""
).fetchone()
return row["n"]
def count_users():
with _lock:
row = _conn.execute("SELECT COUNT(*) AS n FROM users").fetchone()