Esempio 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())
Esempio 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()
    )
Esempio 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()
    )
Esempio 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')
Esempio 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')
Esempio 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())
Esempio 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
Esempio 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