Skip to content

Instantly share code, notes, and snippets.

@categulario
Created July 27, 2017 22:40
Show Gist options
  • Save categulario/165c4dbcdc5b24084afff2c56453ad27 to your computer and use it in GitHub Desktop.
Save categulario/165c4dbcdc5b24084afff2c56453ad27 to your computer and use it in GitHub Desktop.
def login_required(view):
@wraps(view)
def decorated(*args, **kwargs):
auth = request.authorization
if auth is None:
abort(401)
user = User.get_by('api_key', auth.password)
if user is not None:
g.user = user
return view(*args, **kwargs)
return decorated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment