admin.py 733 Bytes
Newer Older
1
""" Main Controller to run the application with some privileges.
2 3 4

"""

5
@auth.requires(True, requires_login=not request.is_local)
6
def index():
7

8 9
    # login procedure is active
    if session.auth:
10
        roles = session.auth.user_groups.values()
11

12 13
        if roles:
            session.role = roles[0]
14

15 16
            # inhibit USER login from the application properties
            if session.role == USER:
17
                if not current.app.authorize_user_login:
18
                    session.role = None
19

20 21
        else:
            return 'The user role is not defined'
22 23

    # no login procedure
24
    else:
25
        session.role = ADMIN
26

27 28
    url = URL('plugin_dbui', 'index', args=request.args, vars=request.vars)
    return redirect(url)