From c40f2ff02957e2bcac9c2e6836f2ce06944974c8 Mon Sep 17 00:00:00 2001 From: Jakob Moser <moser@cl.uni-heidelberg.de> Date: Sat, 17 Aug 2024 15:33:53 +0200 Subject: [PATCH] Rearrange lines (first "assert" authorization type, then check payload) --- portal/api/auth.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/portal/api/auth.py b/portal/api/auth.py index eae75b8..c46263e 100644 --- a/portal/api/auth.py +++ b/portal/api/auth.py @@ -16,9 +16,9 @@ from .blueprint import bp def set_user_if_valid() -> None: if ( not request.authorization + or request.authorization.type != "basic" or request.authorization.username is None or request.authorization.password is None - or request.authorization.type != "basic" ): g.user = None return @@ -32,8 +32,8 @@ def set_user_if_valid() -> None: def set_key_if_valid() -> None: if ( not request.authorization - or request.authorization.token is None or request.authorization.type != "bearer" + or request.authorization.token is None ): g.key = None return -- GitLab