-
-
Save js2854/0ce82ef6d1d5811abb2e19b693b6c29f to your computer and use it in GitHub Desktop.
@login_required decorator to use with bottle.py
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
from bottle import * | |
from bottlepy_user_auth import User | |
def validate_login(): | |
return User().loggedin | |
def login_required(view, check_func=validate_login): | |
''' | |
Check if user has logined to app | |
''' | |
def wrapped(*args, **kwargs): | |
auth = check_func() | |
if auth: | |
return view(*args, **kwargs) | |
return redirect('/login/') | |
return wrapped |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment