Better error handling for missing authentication
All checks were successful
buildbot/multibuild_parent Build done.
buildbot/travis_bionic Build done.

This commit is contained in:
Peter Šurda 2023-12-04 16:06:22 +08:00
parent 63efe9830f
commit 278b442aab
Signed by: PeterSurda
GPG Key ID: 3E47497CF67ABB95

View File

@ -58,7 +58,11 @@ class Root:
@cherrypy.expose @cherrypy.expose
def todo(self): def todo(self):
authorization = cherrypy.request.headers.get('Authorization', ':') authorization = cherrypy.request.headers.get('Authorization', ':')
if not authorization:
raise cherrypy.HTTPError(401, 'Unauthorized')
token = get_token(authorization) token = get_token(authorization)
if not token:
raise cherrypy.HTTPError(401, 'Unauthorized')
combined = get_combined(token) combined = get_combined(token)
if not combined: if not combined:
raise cherrypy.HTTPError(401, 'Unauthorized') raise cherrypy.HTTPError(401, 'Unauthorized')