Exemplo n.º 1
0
def admin():
    """Super-admin page; allows roles to be changed. Don't advertise.
    Misuse will totally break everything."""
    aaa.require(role='admin', fail_redirect='/sorry_page')
    return dict(current_user=aaa.current_user,
                users=aaa.list_users(),
                roles=aaa.list_roles())
Exemplo n.º 2
0
def admin():
    """Regular, more user-friendly admin."""
    aaa.require(role='admin', fail_redirect='/sorry_page')
    return dict(
        current_user=aaa.current_user,
        users=aaa.list_users(),
        roles=aaa.list_roles()
    )
Exemplo n.º 3
0
def admin():
    """Super-admin page; allows roles to be changed. Don't advertise.
    Misuse will totally break everything."""
    aaa.require(role='admin', fail_redirect='/sorry_page')
    return dict(
        current_user=aaa.current_user,
        users=aaa.list_users(),
        roles=aaa.list_roles()
    )
Exemplo n.º 4
0
def toggle_role(username):
    aaa.require(role='admin', fail_redirect='/sorry_page')
    user = aaa.user(username)
    role = user.role
    try:
        if role == 'user':
            user.update(role='admin')
        else:
            user.update(role='user')
    except Exception as e:
        return e.message

    bottle.redirect('/admin')
Exemplo n.º 5
0
def toggle_role(username):
    aaa.require(role='admin', fail_redirect='/sorry_page')
    user = aaa.user(username)
    role = user.role
    try:
        if role == 'user':
            user.update(role='admin')
        else:
            user.update(role='user')
    except Exception as e:
        return e.message

    bottle.redirect('/admin')
Exemplo n.º 6
0
def admin():
    """Regular, more user-friendly admin."""
    aaa.require(role='admin', fail_redirect='/sorry_page')
    return dict(current_user=aaa.current_user,
                users=aaa.list_users(),
                roles=aaa.list_roles())
Exemplo n.º 7
0
def show_current_user_role():
    """Show current user role"""
    session = bottle.request.environ.get('beaker.session')
    print "Session from simple_webapp", repr(session)
    aaa.require(fail_redirect='/login')
    return aaa.current_user.role
Exemplo n.º 8
0
def show_current_user_role():
    """Show current user role"""
    session = bottle.request.environ.get('beaker.session')
    print "Session from simple_webapp", repr(session)
    aaa.require(fail_redirect='/login')
    return aaa.current_user.role