Add field 'acitve' to user authentication
This commit is contained in:
Binary file not shown.
@@ -163,7 +163,7 @@ def load_credentials_from_db() -> dict:
|
||||
|
||||
with closing(get_conn()) as conn:
|
||||
rows = conn.execute(
|
||||
"SELECT username, email, password_hash FROM users"
|
||||
"SELECT username, email, password_hash FROM users where active = 1"
|
||||
).fetchall()
|
||||
|
||||
for username, email, pw_hash in rows:
|
||||
|
||||
@@ -120,8 +120,11 @@ def dialog_modify_user(id):
|
||||
idx = roles.index(role)
|
||||
except:
|
||||
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"])
|
||||
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_lastname = st.text_input(label="Nachname", value=df.iloc[0]["lastname"])
|
||||
txt_email = st.text_input(label="Email", value=df.iloc[0]["email"])
|
||||
@@ -137,6 +140,7 @@ def dialog_modify_user(id):
|
||||
sql = """
|
||||
update users set
|
||||
username = ?,
|
||||
active = ?,
|
||||
firstname = ?,
|
||||
lastname = ?,
|
||||
email = ?,
|
||||
@@ -145,12 +149,13 @@ def dialog_modify_user(id):
|
||||
role_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))
|
||||
else:
|
||||
sql = """
|
||||
update users set
|
||||
username = ?,
|
||||
active = ?,
|
||||
firstname = ?,
|
||||
lastname = ?,
|
||||
email = ?,
|
||||
@@ -158,7 +163,7 @@ def dialog_modify_user(id):
|
||||
role_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))
|
||||
print (params)
|
||||
if send_cmd(sql, params):
|
||||
|
||||
Reference in New Issue
Block a user