FauziIsyrinApridal commited on
Commit
4d7e1af
Β·
1 Parent(s): ec9690d
Files changed (2) hide show
  1. app/auth.py +11 -0
  2. pages/reset_password.py +35 -14
app/auth.py CHANGED
@@ -31,6 +31,17 @@ def auth_view():
31
  unsafe_allow_html=True
32
  )
33
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  # Auth tabs inside wrapper
36
  tab_login, tab_register, tab_forgot = st.tabs(["Login", "Register", "Forgot Password"])
 
31
  unsafe_allow_html=True
32
  )
33
 
34
+ # Hide sidebar and hamburger while on auth screens
35
+ st.markdown(
36
+ """
37
+ <style>
38
+ [data-testid="stSidebar"] { display: none !important; }
39
+ [data-testid="collapsedControl"] { display: none !important; }
40
+ </style>
41
+ """,
42
+ unsafe_allow_html=True,
43
+ )
44
+
45
 
46
  # Auth tabs inside wrapper
47
  tab_login, tab_register, tab_forgot = st.tabs(["Login", "Register", "Forgot Password"])
pages/reset_password.py CHANGED
@@ -9,19 +9,15 @@ def main():
9
 
10
  st.set_page_config(
11
  page_title="Reset Password - PNP Bot",
12
- page_icon="assets/favicon.ico",
13
  initial_sidebar_state="collapsed",
14
  )
15
- # Hide Streamlit sidebar and multipage navigator for this page
16
  st.markdown(
17
  """
18
  <style>
19
- /* Hide full sidebar area */
20
  [data-testid="stSidebar"] { display: none !important; }
21
- /* Hide the multipage navigator that normally appears in the sidebar */
22
- [data-testid="stSidebarNav"] { display: none !important; }
23
- /* Expand main content to full width since sidebar is hidden */
24
- [data-testid="stAppViewContainer"] > .main { width: 100%; }
25
  </style>
26
  """,
27
  unsafe_allow_html=True,
@@ -68,7 +64,16 @@ def main():
68
  st.info("Silakan kembali ke halaman login dan minta link reset password yang baru.")
69
 
70
  if st.button("← Kembali ke Login", type="primary"):
71
- st.switch_page("app.py")
 
 
 
 
 
 
 
 
 
72
  return
73
 
74
  # Reset password form
@@ -95,7 +100,15 @@ def main():
95
  cancel_reset = st.form_submit_button("❌ Batal", use_container_width=True)
96
 
97
  if cancel_reset:
98
- st.switch_page("app.py")
 
 
 
 
 
 
 
 
99
 
100
  if submit_reset:
101
  # Validation
@@ -124,11 +137,19 @@ def main():
124
  st.success("βœ… Password berhasil diubah!")
125
  st.info("Silakan login dengan password baru Anda.")
126
 
127
- # Show countdown and redirect button
128
- st.markdown("*Klik tombol di bawah untuk kembali ke halaman login.*")
129
-
130
- if st.button("🏠 Kembali ke Login", type="primary"):
131
- st.switch_page("app.py")
 
 
 
 
 
 
 
 
132
  else:
133
  st.error("❌ Gagal mengubah password. Silakan coba lagi.")
134
 
 
9
 
10
  st.set_page_config(
11
  page_title="Reset Password - PNP Bot",
12
+ page_icon="assets/favicon.ico",
13
  initial_sidebar_state="collapsed",
14
  )
15
+ # Hide sidebar and hamburger completely
16
  st.markdown(
17
  """
18
  <style>
 
19
  [data-testid="stSidebar"] { display: none !important; }
20
+ [data-testid="collapsedControl"] { display: none !important; }
 
 
 
21
  </style>
22
  """,
23
  unsafe_allow_html=True,
 
64
  st.info("Silakan kembali ke halaman login dan minta link reset password yang baru.")
65
 
66
  if st.button("← Kembali ke Login", type="primary"):
67
+ # Redirect to root (main app)
68
+ st.markdown(
69
+ """
70
+ <script>
71
+ window.location.href = window.location.origin +
72
+ (window.location.pathname.replace(/\/?pages\/?reset_password\/?$/,'/') || '/');
73
+ </script>
74
+ """,
75
+ unsafe_allow_html=True,
76
+ )
77
  return
78
 
79
  # Reset password form
 
100
  cancel_reset = st.form_submit_button("❌ Batal", use_container_width=True)
101
 
102
  if cancel_reset:
103
+ st.markdown(
104
+ """
105
+ <script>
106
+ window.location.href = window.location.origin +
107
+ (window.location.pathname.replace(/\/?pages\/?reset_password\/?$/,'/') || '/');
108
+ </script>
109
+ """,
110
+ unsafe_allow_html=True,
111
+ )
112
 
113
  if submit_reset:
114
  # Validation
 
137
  st.success("βœ… Password berhasil diubah!")
138
  st.info("Silakan login dengan password baru Anda.")
139
 
140
+ # Show countdown and auto-redirect to main app
141
+ st.markdown(
142
+ """
143
+ <script>
144
+ setTimeout(function(){
145
+ window.location.href = window.location.origin +
146
+ (window.location.pathname.replace(/\/?pages\/?reset_password\/?$/,'/') || '/');
147
+ }, 1500);
148
+ </script>
149
+ """,
150
+ unsafe_allow_html=True,
151
+ )
152
+ st.caption("Mengalihkan ke halaman login...")
153
  else:
154
  st.error("❌ Gagal mengubah password. Silakan coba lagi.")
155