From ff6c973eeff35f57928f83df1db77b549e2f9bc4 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 30 Oct 2020 22:17:43 +0100 Subject: [PATCH] [System] Fixed issue when Authorization header is missing --- flaschengeist/decorator.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/flaschengeist/decorator.py b/flaschengeist/decorator.py index 848b0ee..9e2bbfd 100644 --- a/flaschengeist/decorator.py +++ b/flaschengeist/decorator.py @@ -20,7 +20,11 @@ def login_required(permission=None): def wrap(func): @wraps(func) def wrapped_f(*args, **kwargs): - token = list(filter(None, request.headers.get("Authorization").split(" ")))[-1] + try: + token = list(filter(None, request.headers.get("Authorization").split(" ")))[-1] + except AttributeError: + raise Unauthorized + session = sessionController.validate_token(token, request.user_agent, permission) if session: kwargs["current_session"] = session