Reduce nesting for the sample authentication decorator (#1715)

* Reduce nesting for the sample authentication decorator

* Add missing decorator argument
This commit is contained in:
Vinícius Dantas 2019-11-14 17:57:41 -03:00 committed by Stephen Sadowski
parent a4185a0ba7
commit ed1f367a8a

View File

@ -13,8 +13,7 @@ def check_request_for_authorization_status(request):
return flag
def authorized():
def decorator(f):
def authorized(f):
@wraps(f)
async def decorated_function(request, *args, **kwargs):
# run some method that checks the request
@ -30,11 +29,10 @@ def authorized():
# the user is not authorized.
return json({'status': 'not_authorized'}, 403)
return decorated_function
return decorator
@app.route("/")
@authorized()
@authorized
async def test(request):
return json({'status': 'authorized'})