AIdeaText commited on
Commit
e5d0ce8
1 Parent(s): 8510bd0

Update modules/ui.py

Browse files
Files changed (1) hide show
  1. modules/ui.py +25 -30
modules/ui.py CHANGED
@@ -20,23 +20,6 @@ from .semantic_analysis import visualize_semantic_relations, perform_semantic_an
20
  from .discourse_analysis import compare_semantic_analysis, perform_discourse_analysis
21
  from .chatbot import initialize_chatbot, get_chatbot_response
22
 
23
-
24
- ##################################################################################################
25
- def main():
26
- if 'logged_in' not in st.session_state:
27
- st.session_state.logged_in = False
28
-
29
- if not st.session_state.logged_in:
30
- login_register_page()
31
- else:
32
- if st.session_state.role == 'admin':
33
- admin_page()
34
- else:
35
- user_page() # Esta sería la página normal para estudiantes
36
-
37
- if __name__ == "__main__":
38
- main()
39
-
40
  ##################################################################################################
41
  def login_register_page():
42
  st.title("AIdeaText")
@@ -96,24 +79,36 @@ def login_register_page():
96
  ##################################################################################################
97
  def login_form():
98
  username = st.text_input("Correo electrónico")
99
- password = st.text_input("Contraseña", type='password')
100
- captcha_answer = st.text_input("Captcha: ¿Cuánto es 2 + 3?")
101
 
102
  if st.button("Iniciar Sesión"):
103
- if captcha_answer == "5":
104
- if authenticate_user(username, password):
105
- st.success(f"Bienvenido, {username}!")
106
- st.session_state.logged_in = True
107
- st.session_state.username = username
108
- st.session_state.role = get_user_role(username)
109
- st.experimental_rerun()
110
- else:
111
- st.error("Usuario o contraseña incorrectos")
 
 
 
 
 
 
 
 
 
 
112
  else:
113
- st.error("Captcha incorrecto")
 
 
 
 
114
 
115
  ##################################################################################################
116
- # En ui.py
117
  def admin_page():
118
  st.title("Panel de Administración")
119
 
 
20
  from .discourse_analysis import compare_semantic_analysis, perform_discourse_analysis
21
  from .chatbot import initialize_chatbot, get_chatbot_response
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  ##################################################################################################
24
  def login_register_page():
25
  st.title("AIdeaText")
 
79
  ##################################################################################################
80
  def login_form():
81
  username = st.text_input("Correo electrónico")
82
+ password = st.text_input("Contraseña", type="password")
 
83
 
84
  if st.button("Iniciar Sesión"):
85
+ success, role = authenticate_user(username, password)
86
+ if success:
87
+ st.session_state.logged_in = True
88
+ st.session_state.username = username
89
+ st.session_state.role = role
90
+ st.experimental_rerun()
91
+ else:
92
+ st.error("Credenciales incorrectas")
93
+
94
+ ##################################################################################################
95
+ def main():
96
+ if 'logged_in' not in st.session_state:
97
+ st.session_state.logged_in = False
98
+
99
+ if not st.session_state.logged_in:
100
+ login_register_page()
101
+ else:
102
+ if st.session_state.role == 'admin':
103
+ admin_page()
104
  else:
105
+ user_page() # Esta sería la página normal para estudiantes
106
+
107
+ if __name__ == "__main__":
108
+ main()
109
+
110
 
111
  ##################################################################################################
 
112
  def admin_page():
113
  st.title("Panel de Administración")
114