Simplify code section

This commit is contained in:
Matthias 2020-05-10 19:43:16 +02:00
parent 21c2af2b92
commit d291ca0071

View File

@ -45,8 +45,7 @@ def require_login(func: Callable[[Any, Any], Any]):
def func_wrapper(obj, *args, **kwargs): def func_wrapper(obj, *args, **kwargs):
verify_jwt_in_request_optional() verify_jwt_in_request_optional()
auth = request.authorization auth = request.authorization
i = get_jwt_identity() if get_jwt_identity() or auth and obj.check_auth(auth.username, auth.password):
if i or auth and obj.check_auth(auth.username, auth.password):
return func(obj, *args, **kwargs) return func(obj, *args, **kwargs)
else: else:
return jsonify({"error": "Unauthorized"}), 401 return jsonify({"error": "Unauthorized"}), 401