You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/libinspector/common.py
+45-22Lines changed: 45 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,31 @@
26
26
"- Metadata of your network traffic (e.g., which IPs/domains your devices communicate with) is shared anonymously with NYU researchers during the labeling stage."
27
27
)
28
28
29
+
defremove_warning():
30
+
"""
31
+
Remove the warning acceptance state, forcing the user to see the warning again.
32
+
"""
33
+
config_set("suppress_warning", True)
34
+
35
+
36
+
defreset_prolific_id():
37
+
"""
38
+
Clear the stored Prolific ID, forcing the user to re-enter it.
39
+
"""
40
+
config_set("prolific_id", "")
41
+
42
+
43
+
defset_prolific_id(prolific_id: str):
44
+
"""
45
+
Store the provided Prolific ID in the configuration.
46
+
47
+
Args:
48
+
prolific_id (str): The Prolific ID to store.
49
+
"""
50
+
ifis_prolific_id_valid(prolific_id):
51
+
config_set("prolific_id", prolific_id)
52
+
53
+
29
54
defshow_warning():
30
55
"""
31
56
Displays a warning message to the user about network monitoring and ARP spoofing.
@@ -36,28 +61,30 @@ def show_warning():
36
61
False if the user has accepted the warning and can proceed.
37
62
"""
38
63
current_id=config_get("prolific_id", "")
64
+
st.subheader("1. Prolific ID Confirmation")
65
+
st.info(f"Your currently stored ID is: `{current_id}`")
66
+
st.button("Change Prolific ID",
67
+
on_click=reset_prolific_id,
68
+
help="Clicking this will clear your stored ID and return you to the ID entry form.")
39
69
40
70
# --- GATE 1: PROLIFIC ID CHECK (Must be valid to proceed to confirmation) ---
41
71
ifis_prolific_id_valid(current_id):
42
-
# --- SHOW CONFIRMATION UI (Only reached if ID is valid but warning is unaccepted) ---
43
-
st.subheader("1. Prolific ID Confirmation")
44
-
st.info(f"Your currently stored ID is: `{current_id}`")
45
-
46
-
# Allows the user to change the ID, which forces them back through GATE 1
47
-
ifst.button("Change Prolific ID", help="Clicking this will clear your stored ID and return you to the ID entry form."):
48
-
config_set("prolific_id", "") # Clear the stored ID
49
-
st.rerun()
50
-
72
+
# Check if the warning is NOT suppressed. If it's not suppressed, we show the UI
73
+
# and MUST return True (Block execution) until the user clicks the button.
51
74
ifnotconfig_get("suppress_warning", False):
52
75
st.markdown("---")
53
76
st.subheader("2. Network Monitoring Warning")
54
77
st.markdown(warning_text)
55
78
56
-
ifst.button("OK, I understand and wish to proceed", help="Clicking this confirms that you understand the warning and wish to proceed."):
57
-
config_set("suppress_warning", True)
58
-
st.rerun()
79
+
st.button("OK, I understand and wish to proceed",
80
+
on_click=remove_warning,
81
+
help="Clicking this confirms that you understand the warning and wish to proceed.")
82
+
83
+
# Since the warning is displayed and unaccepted, we must block.
0 commit comments