Fix login system: add health route exemption, translate comments

- Add 'health' to allowed routes to prevent Docker healthcheck failures
- Translate Spanish comments to English for consistency
- Reset binary database file to avoid committing user data

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-01-11 20:39:44 +00:00
parent f51b193876
commit cf91c2484f
2 changed files with 8 additions and 8 deletions
+8 -8
View File
@@ -146,10 +146,10 @@ cleanup_manager.register(adsb_aircraft)
@app.before_request @app.before_request
def require_login(): def require_login():
# Lista de rutas que NO requieren login (para evitar un bucle infinito) # Routes that don't require login (to avoid infinite redirect loop)
allowed_routes = ['login', 'static', 'favicon'] allowed_routes = ['login', 'static', 'favicon', 'health']
# Si el usuario no está logueado y la ruta actual no está permitida... # If user is not logged in and the current route is not allowed...
if 'logged_in' not in session and request.endpoint not in allowed_routes: if 'logged_in' not in session and request.endpoint not in allowed_routes:
return redirect(url_for('login')) return redirect(url_for('login'))
@@ -164,17 +164,17 @@ def login():
username = request.form.get('username') username = request.form.get('username')
password = request.form.get('password') password = request.form.get('password')
# 1. Conectar a la DB y buscar al usuario # Connect to DB and find user
with get_db() as conn: with get_db() as conn:
cursor = conn.execute( cursor = conn.execute(
'SELECT password_hash, role FROM users WHERE username = ?', 'SELECT password_hash, role FROM users WHERE username = ?',
(username,) (username,)
) )
user = cursor.fetchone() user = cursor.fetchone()
# 2. Verificar si el usuario existe y la contraseña es correcta # Verify user exists and password is correct
if user and check_password_hash(user['password_hash'], password): if user and check_password_hash(user['password_hash'], password):
# Guardamos datos en la sesión # Store data in session
session['logged_in'] = True session['logged_in'] = True
session['username'] = username session['username'] = username
session['role'] = user['role'] session['role'] = user['role']
Binary file not shown.