def require_password(func):
""" verifies the given username/password combo """
@wraps(func)
def decorator(*args, **kwargs):
if request.authorization:
username = request.authorization.username
password = request.authorization.password
try:
manager = AccountManager()
valid = manager.verify_account(username, password)
if not valid:
return UnauthorizedResponseJson().make_response()
except Exception as e:
traceback.print_exc()
return ExceptionResponseJson("unable to validate credentials", e).make_response()
else:
return UnauthorizedResponseJson().make_response()
return func(*args, **kwargs)
return decorator
评论列表
文章目录