From 278b442aab94737b2cd459930a3c9283794d022d Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Mon, 4 Dec 2023 16:06:22 +0800 Subject: [PATCH] Better error handling for missing authentication --- gitea-to-ics.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gitea-to-ics.py b/gitea-to-ics.py index 414c8e3..a0e4df1 100644 --- a/gitea-to-ics.py +++ b/gitea-to-ics.py @@ -58,7 +58,11 @@ class Root: @cherrypy.expose def todo(self): authorization = cherrypy.request.headers.get('Authorization', ':') + if not authorization: + raise cherrypy.HTTPError(401, 'Unauthorized') token = get_token(authorization) + if not token: + raise cherrypy.HTTPError(401, 'Unauthorized') combined = get_combined(token) if not combined: raise cherrypy.HTTPError(401, 'Unauthorized')