|
48 | 48 | GBIF_DB_PATH = os.path.join(DATA_DIR, "gbif_selected_FI_NO_merged.tsv") |
49 | 49 | LIST_PLANTS_GENERA_PATH = os.path.join(DATA_DIR, "selected_genera.txt") |
50 | 50 |
|
| 51 | +# Hard-coded app password; change the value to update access |
| 52 | +APP_PASSWORD = "metformin" |
| 53 | + |
51 | 54 | st.set_page_config(page_title="AURORA Pilot", layout="wide") |
52 | 55 |
|
53 | 56 | # ---- Session state init (so tables persist after any rerun, e.g., download clicks) ---- |
|
64 | 67 | "similarity_table": None, |
65 | 68 | "active_smiles_query": None, |
66 | 69 | "similarity_error": None, |
| 70 | + "auth_ok": False, |
| 71 | + "auth_error": False, |
67 | 72 | }.items(): |
68 | 73 | if k not in st.session_state: |
69 | 74 | st.session_state[k] = v |
70 | 75 |
|
| 76 | + |
| 77 | +def require_password(): |
| 78 | + """Optional password gate that does not disturb the rest of the UI.""" |
| 79 | + if not APP_PASSWORD: |
| 80 | + return |
| 81 | + if st.session_state.get("auth_ok"): |
| 82 | + return |
| 83 | + |
| 84 | + if st.session_state.get("auth_error"): |
| 85 | + st.error("Incorrect password, please try again.") |
| 86 | + |
| 87 | + with st.form("auth_form"): |
| 88 | + st.subheader("Enter password to continue") |
| 89 | + password = st.text_input("Password", type="password") |
| 90 | + submitted = st.form_submit_button("Unlock") |
| 91 | + |
| 92 | + if submitted: |
| 93 | + if password == APP_PASSWORD: |
| 94 | + st.session_state["auth_ok"] = True |
| 95 | + st.session_state["auth_error"] = False |
| 96 | + st.rerun() |
| 97 | + else: |
| 98 | + st.session_state["auth_error"] = True |
| 99 | + |
| 100 | + if not st.session_state.get("auth_ok"): |
| 101 | + st.stop() |
| 102 | + |
71 | 103 | QUERY_PARAM_KEY = "select_compound" |
72 | 104 | query_params: dict[str, list[str] | str] = {} |
73 | 105 | raw_query_params = getattr(st, "query_params", None) |
|
101 | 133 | st.session_state["compound_input"] = st.session_state.pop("pending_compound") |
102 | 134 | st.session_state["auto_run"] = True |
103 | 135 |
|
| 136 | +require_password() |
| 137 | + |
104 | 138 | # Cap the overall content width and shrink the first (#) column |
105 | 139 | st.markdown( |
106 | 140 | """ |
@@ -714,6 +748,7 @@ def display_similarity_section(similarity_df: pd.DataFrame, compound_name: str | |
714 | 748 | # Text input allows free-form entry for names or SMILES strings |
715 | 749 | compound = st.text_input( |
716 | 750 | "Compound", |
| 751 | + value=st.session_state.get("compound_input", DEFAULT_COMPOUND), |
717 | 752 | key="compound_input", |
718 | 753 | help="Enter a compound name.", |
719 | 754 | ) |
@@ -893,4 +928,4 @@ def display_similarity_section(similarity_df: pd.DataFrame, compound_name: str | |
893 | 928 | ) |
894 | 929 |
|
895 | 930 |
|
896 | | -st.caption('<span style="font-size: x-small;">App version: 3.1; © 2025 Daniel Nicorici, Juha Klefström — University of Helsinki</span>', unsafe_allow_html=True) |
| 931 | +st.caption('<span style="font-size: x-small;">App version: 3.2; © 2025 Daniel Nicorici, Juha Klefström — University of Helsinki</span>', unsafe_allow_html=True) |
0 commit comments