mirror of
https://github.com/smittix/intercept.git
synced 2026-07-24 16:58:12 -07:00
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:
@@ -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,7 +164,7 @@ 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 = ?',
|
||||||
@@ -172,9 +172,9 @@ def login():
|
|||||||
)
|
)
|
||||||
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.
Reference in New Issue
Block a user