Skip to content

Instantly share code, notes, and snippets.

@vsergeyev
Last active September 28, 2018 01:34
Show Gist options
  • Save vsergeyev/4461139 to your computer and use it in GitHub Desktop.
Save vsergeyev/4461139 to your computer and use it in GitHub Desktop.
@login_required decorator to use with bottle.py
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