Skip to content

🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!

Backend: keep JSON 500s for unhandled route errors in token_required

João Alves3fe1ca8ed2ac
diff --git a/backend/auth_utils.py b/backend/auth_utils.py
index dce6f5a..1a60e8c 100644
--- a/backend/auth_utils.py
+++ b/backend/auth_utils.py
@@ -110,7 +110,13 @@ def token_required(f):
'oidc_managed': user[5] is not None
})
- return f(*args, **kwargs)
+ try:
+ return f(*args, **kwargs)
+ except HTTPException:
+ raise
+ except Exception:
+ current_app.logger.exception(f"Unhandled error in {request.path}")
+ return jsonify({'message': 'Authentication error!'}), 500
return decorated