Created
October 1, 2018 12:05
-
-
Save js2854/2e969017d20acf9e1dc19ec372037418 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from functools import wraps | |
from bottle import request | |
def login(): | |
def decorator(func): | |
@wraps(func) | |
def wrapper(auth, *args, **kwargs): | |
try: | |
auth.get_user(request.environ) | |
return func(*args, **kwargs) | |
except: | |
return auth.redirect(request.environ) | |
return wrapper | |
return decorator | |
# @app.route('/') | |
# @login() | |
# def home(): | |
# user = auth.get_user(request.environ) | |
# return "Home page {}".format(pformat(user)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment