示例#1
0
文件: pages.py 项目: val314159/corked
def admin():
    """Only admin users can see this"""
    backend.require(role='admin', fail_redirect='/sorry_page')
    return dict(
        current_user=backend.current_user,
        users=backend.list_users(),
        roles=backend.list_roles())
示例#2
0
文件: pages.py 项目: val314159/corked
def auth_require():
    """Only authenticated users can see this"""
    add_headers(bottle.response)
    if bottle.request.method in ['HEAD','OPTIONS']:
        return []
    try:
        if backend.require():
            return dict()
    except:
        pass
    return dict(success=False, errmsg='Access Denied')
示例#3
0
文件: pages.py 项目: val314159/corked
def show_current_user_role():
    """Show current user role"""
    session = bottle.request.environ.get('beaker.session')
    print "Session from simple_webapp", repr(session)
    backend.require(fail_redirect='/login')
    return backend.current_user.role
示例#4
0
文件: pages.py 项目: val314159/corked
def restricted_download():
    """Only authenticated users can download this file"""
    backend.require(fail_redirect='/login')
    return bottle.static_file('static_file', root='.')
示例#5
0
文件: pages.py 项目: val314159/corked
def index():
    """Only authenticated users can see this"""
    backend.require(fail_redirect='/login')
    return 'Welcome! <a href="/admin">Admin page</a> <a href="/logout">Logout</a>'