def needs_authentication():
"""
Decorator: Attach this to a route and it will require that the session has been
previously authenticated.
"""
def auth_chk_wrapper(f):
# This is our decoratorated function wrapper
@wraps(f)
def deco(*args, **kwargs):
# If the session does not yet have an authentication
if not is_authenticated():
return redirect(sign_auth_path(request.full_path))
else:
return f(*args, **kwargs)
return deco
return auth_chk_wrapper
评论列表
文章目录