Update modules/ui/login_ui.py
Browse files- modules/ui/login_ui.py +21 -20
modules/ui/login_ui.py
CHANGED
|
@@ -1,36 +1,37 @@
|
|
| 1 |
#modules/ui/login_ui.py
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
-
from modules.auth.auth import authenticate_user
|
| 5 |
|
| 6 |
def create_login_interface():
|
| 7 |
"""
|
| 8 |
-
Interfaz de
|
| 9 |
"""
|
| 10 |
with gr.Blocks() as login_interface:
|
| 11 |
gr.Markdown("# Iniciar Sesi贸n")
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
message = gr.Markdown()
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
success, role = authenticate_user(user, pwd)
|
| 19 |
-
return f"Bienvenido, {user} ({role})" if success else "Credenciales incorrectas."
|
| 20 |
-
|
| 21 |
-
login_btn.click(fn=handle_login, inputs=[username, password], outputs=message)
|
| 22 |
-
|
| 23 |
-
back_button = gr.Button("Volver a la P谩gina Principal")
|
| 24 |
-
|
| 25 |
-
def render(navigate_back):
|
| 26 |
-
"""
|
| 27 |
-
Renderiza la p谩gina con la funcionalidad de navegaci贸n.
|
| 28 |
-
"""
|
| 29 |
back_button.click(
|
| 30 |
fn=navigate_back,
|
| 31 |
inputs=[],
|
| 32 |
outputs=[]
|
| 33 |
)
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
login_interface.render = render
|
| 36 |
-
return login_interface
|
|
|
|
| 1 |
#modules/ui/login_ui.py
|
| 2 |
|
| 3 |
import gradio as gr
|
|
|
|
| 4 |
|
| 5 |
def create_login_interface():
|
| 6 |
"""
|
| 7 |
+
Interfaz de inicio de sesi贸n.
|
| 8 |
"""
|
| 9 |
with gr.Blocks() as login_interface:
|
| 10 |
gr.Markdown("# Iniciar Sesi贸n")
|
| 11 |
+
|
| 12 |
+
with gr.Row():
|
| 13 |
+
username = gr.Textbox(label="Usuario")
|
| 14 |
+
with gr.Row():
|
| 15 |
+
password = gr.Textbox(label="Contrase帽a", type="password")
|
| 16 |
+
|
| 17 |
+
with gr.Row():
|
| 18 |
+
back_button = gr.Button("Volver")
|
| 19 |
+
login_button = gr.Button("Iniciar Sesi贸n", variant="primary")
|
| 20 |
+
|
| 21 |
message = gr.Markdown()
|
| 22 |
+
|
| 23 |
+
def render(navigate_back, handle_login):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
back_button.click(
|
| 25 |
fn=navigate_back,
|
| 26 |
inputs=[],
|
| 27 |
outputs=[]
|
| 28 |
)
|
| 29 |
+
|
| 30 |
+
login_button.click(
|
| 31 |
+
fn=handle_login,
|
| 32 |
+
inputs=[username, password],
|
| 33 |
+
outputs=[message]
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
login_interface.render = render
|
| 37 |
+
return login_interface
|