Add field 'acitve' to user authentication

This commit is contained in:
knedlik
2025-12-19 08:27:36 +01:00
parent 37d1daa052
commit 9c5ed967ec
3 changed files with 10 additions and 5 deletions

Binary file not shown.

View File

@@ -163,7 +163,7 @@ def load_credentials_from_db() -> dict:
with closing(get_conn()) as conn: with closing(get_conn()) as conn:
rows = conn.execute( rows = conn.execute(
"SELECT username, email, password_hash FROM users" "SELECT username, email, password_hash FROM users where active = 1"
).fetchall() ).fetchall()
for username, email, pw_hash in rows: for username, email, pw_hash in rows:

View File

@@ -120,8 +120,11 @@ def dialog_modify_user(id):
idx = roles.index(role) idx = roles.index(role)
except: except:
idx = None idx = None
col1, col2 = st.columns([2,1],vertical_alignment="center")
with col1:
txt_username = st.text_input(label="Benutzername", value=df.iloc[0]["user"]) txt_username = st.text_input(label="Benutzername", value=df.iloc[0]["user"])
with col2:
is_active = st.checkbox(label="Aktiv", value=df.iloc[0]["active"])
txt_firstname = st.text_input(label="Vorname", value=df.iloc[0]["firstname"]) txt_firstname = st.text_input(label="Vorname", value=df.iloc[0]["firstname"])
txt_lastname = st.text_input(label="Nachname", value=df.iloc[0]["lastname"]) txt_lastname = st.text_input(label="Nachname", value=df.iloc[0]["lastname"])
txt_email = st.text_input(label="Email", value=df.iloc[0]["email"]) txt_email = st.text_input(label="Email", value=df.iloc[0]["email"])
@@ -137,6 +140,7 @@ def dialog_modify_user(id):
sql = """ sql = """
update users set update users set
username = ?, username = ?,
active = ?,
firstname = ?, firstname = ?,
lastname = ?, lastname = ?,
email = ?, email = ?,
@@ -145,12 +149,13 @@ def dialog_modify_user(id):
role_id = ? role_id = ?
where id = ? where id = ?
""" """
params = (txt_username, txt_firstname, txt_lastname, txt_email, pw_hash, new_pwd, get_id(cmb_role), id) params = (txt_username, is_active, txt_firstname, txt_lastname, txt_email, pw_hash, new_pwd, get_id(cmb_role), id)
# send_cmd(sql,(txt_username, txt_firstname, txt_lastname, txt_email, pw_hash, new_pwd, get_id(cmb_role), id)) # send_cmd(sql,(txt_username, txt_firstname, txt_lastname, txt_email, pw_hash, new_pwd, get_id(cmb_role), id))
else: else:
sql = """ sql = """
update users set update users set
username = ?, username = ?,
active = ?,
firstname = ?, firstname = ?,
lastname = ?, lastname = ?,
email = ?, email = ?,
@@ -158,7 +163,7 @@ def dialog_modify_user(id):
role_id = ? role_id = ?
where id = ? where id = ?
""" """
params = (txt_username, txt_firstname, txt_lastname, txt_email, new_pwd, get_id(cmb_role), id) params = (txt_username, is_active, txt_firstname, txt_lastname, txt_email, new_pwd, get_id(cmb_role), id)
# send_cmd(sql,(txt_username, txt_firstname, txt_lastname, txt_email, new_pwd, get_id(cmb_role), id)) # send_cmd(sql,(txt_username, txt_firstname, txt_lastname, txt_email, new_pwd, get_id(cmb_role), id))
print (params) print (params)
if send_cmd(sql, params): if send_cmd(sql, params):