Spaces:
Runtime error
Runtime error
Download modules/auth.py from Garimind/GariGariMind-Frontend-Memory-Engine: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/spaces/Garimind/GariGariMind-Frontend-Memory-Engine/resolve/main/modules/auth.py
- Command line
-
hf download hf://spaces/Garimind/GariGariMind-Frontend-Memory-Engine/modules/auth.py
-
curl -L -o auth.py https://huggingface.co/spaces/Garimind/GariGariMind-Frontend-Memory-Engine/resolve/main/modules/auth.py
1.32 kB
| import streamlit as st | |
| from modules.utils.supabase_client import sb | |
| def login_ui(): | |
| st.sidebar.header("馃攼 Iniciar sesi贸n (modo prueba)") | |
| email = st.sidebar.text_input("Correo electr贸nico", placeholder="t煤@empresa.com") | |
| password = st.sidebar.text_input("Contrase帽a", type="password") | |
| if st.sidebar.button("Entrar"): | |
| # ---------------------------------------------------------------- | |
| # En lugar de sb.auth, usamos consulta directa a tu tabla usuarios | |
| resp = sb.table("usuarios") \ | |
| .select("id, email, nombre") \ | |
| .eq("email", email) \ | |
| .eq("password", password) \ | |
| .single() \ | |
| .execute() | |
| if resp.data: | |
| st.sidebar.success(f"隆Hola, {resp.data['nombre']}!") | |
| # Guardamos un objeto user b谩sico en sesi贸n | |
| st.session_state.user = { | |
| "id": resp.data["id"], | |
| "email": resp.data["email"], | |
| "nombre": resp.data["nombre"] | |
| } | |
| else: | |
| st.sidebar.error("Usuario o contrase帽a incorrectos.") | |
| # ---------------------------------------------------------------- | |
| def require_login(): | |
| if "user" not in st.session_state: | |
| st.warning("Por favor, inicia sesi贸n para continuar.") | |
| st.stop() | |