Fix remote portal trip list
- /api/trips now returns {trips:[...]} to match what history.js expects (result.trips)
- odo_start_km null guard in history.js (server trips have no odometer data)
- require_login returns 401 JSON for /api/* paths instead of HTML redirect
Co-authored-by: Copilot <[email protected]>
This commit is contained in:
@@ -38,10 +38,14 @@ def hash_password(plain):
|
||||
|
||||
|
||||
def require_login(view):
|
||||
"""Decorator: redirect to login page if not authenticated."""
|
||||
"""Decorator: redirect to login page if not authenticated (HTML routes),
|
||||
or return 401 JSON for /api/* routes."""
|
||||
@wraps(view)
|
||||
def wrapped(*args, **kwargs):
|
||||
if not current_user.is_authenticated:
|
||||
from flask import request, jsonify
|
||||
if request.path.startswith("/api/"):
|
||||
return jsonify(error="not authenticated"), 401
|
||||
return redirect(url_for("login_page"))
|
||||
return view(*args, **kwargs)
|
||||
return wrapped
|
||||
|
||||
Reference in New Issue
Block a user