Upload 12 files
Browse files- app.py +5 -5
- database.py +14 -2
app.py
CHANGED
|
@@ -159,14 +159,14 @@ if not st.session_state.user:
|
|
| 159 |
# No mostramos la contraseña por seguridad, pero confirmamos que no está vacía
|
| 160 |
print(f"Contraseña introducida: {'Sí' if password else 'No'}")
|
| 161 |
|
| 162 |
-
if row
|
| 163 |
print(f"Usuario encontrado en BD: '{row['username']}'")
|
| 164 |
-
|
| 165 |
-
print(f"
|
| 166 |
-
is_valid = verify_password(password,
|
| 167 |
print(f"Resultado de verify_password: {is_valid}")
|
| 168 |
else:
|
| 169 |
-
print("Usuario no encontrado
|
| 170 |
is_valid = False
|
| 171 |
|
| 172 |
print("--- FIN INTENTO DE LOGIN ---\n")
|
|
|
|
| 159 |
# No mostramos la contraseña por seguridad, pero confirmamos que no está vacía
|
| 160 |
print(f"Contraseña introducida: {'Sí' if password else 'No'}")
|
| 161 |
|
| 162 |
+
if row:
|
| 163 |
print(f"Usuario encontrado en BD: '{row['username']}'")
|
| 164 |
+
stored_pw = (row["password_hash"] or "")
|
| 165 |
+
print(f"Password almacenado (longitud): {len(stored_pw)}")
|
| 166 |
+
is_valid = verify_password(password, stored_pw)
|
| 167 |
print(f"Resultado de verify_password: {is_valid}")
|
| 168 |
else:
|
| 169 |
+
print("Usuario no encontrado en la BD.")
|
| 170 |
is_valid = False
|
| 171 |
|
| 172 |
print("--- FIN INTENTO DE LOGIN ---\n")
|
database.py
CHANGED
|
@@ -40,11 +40,23 @@ def init_schema():
|
|
| 40 |
created_at TEXT NOT NULL
|
| 41 |
);
|
| 42 |
""")
|
| 43 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
try:
|
| 45 |
c.execute("ALTER TABLE users DROP COLUMN pw_hash;")
|
| 46 |
except sqlite3.OperationalError:
|
| 47 |
-
pass
|
| 48 |
# (opcional: tus otras tablas)
|
| 49 |
|
| 50 |
# >>> NUEVA TABLA PARA FEEDBACK DE AD (no depende de videos)
|
|
|
|
| 40 |
created_at TEXT NOT NULL
|
| 41 |
);
|
| 42 |
""")
|
| 43 |
+
# Migraciones: asegurar columnas esperadas
|
| 44 |
+
try:
|
| 45 |
+
c.execute("PRAGMA table_info(users)")
|
| 46 |
+
cols = {row[1] for row in c.fetchall()} # set de nombres de columnas
|
| 47 |
+
if "password_hash" not in cols:
|
| 48 |
+
c.execute("ALTER TABLE users ADD COLUMN password_hash TEXT")
|
| 49 |
+
if "role" not in cols:
|
| 50 |
+
c.execute("ALTER TABLE users ADD COLUMN role TEXT NOT NULL DEFAULT 'verd'")
|
| 51 |
+
if "created_at" not in cols:
|
| 52 |
+
c.execute("ALTER TABLE users ADD COLUMN created_at TEXT NOT NULL DEFAULT ''")
|
| 53 |
+
except sqlite3.OperationalError:
|
| 54 |
+
pass
|
| 55 |
+
# Intento de limpieza de columna antigua si existiera (SQLite no permite DROP COLUMN en versiones antiguas)
|
| 56 |
try:
|
| 57 |
c.execute("ALTER TABLE users DROP COLUMN pw_hash;")
|
| 58 |
except sqlite3.OperationalError:
|
| 59 |
+
pass
|
| 60 |
# (opcional: tus otras tablas)
|
| 61 |
|
| 62 |
# >>> NUEVA TABLA PARA FEEDBACK DE AD (no depende de videos)
|