initial commit

This commit is contained in:
2025-06-03 14:01:08 +00:00
commit 6ab9ceed4b
50 changed files with 2253 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
# dashboard/callbacks/users_callbacks.py
import dash
from dash import Input, Output, State, dcc
from flask import session
from utils.db import execute_query, execute_non_query
from utils.auth import hash_password
@dash.callback(
Output("users-feedback", "children"),
Input("btn-new-user", "n_clicks"),
State("input-new-username", "value"),
State("input-new-password", "value"),
State("input-new-role", "value"),
prevent_initial_call=True
)
def create_user(n_clicks, uname, pwd, role):
if session.get("role") != "admin":
return "Keine Berechtigung."
if n_clicks and n_clicks > 0:
pwd_hash = hash_password(pwd)
sql = "INSERT INTO users (username, pwd_hash, role) VALUES (%s, %s, %s)"
rc = execute_non_query(sql, (uname, pwd_hash, role))
return "Benutzer erstellt." if rc else "Fehler beim Erstellen."
return ""