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

"""
LE GAC Renaud's avatar
LE GAC Renaud committed
4 5 6
from gluon import current
from auth import ADMIN, USER

7

8
@auth.requires(True, requires_login=not request.is_local)
9
def index():
10

11 12
    # login procedure is active
    if session.auth:
13
        roles = session.auth.user_groups.values()
14

15 16
        if roles:
            session.role = roles[0]
17

18 19
            # inhibit USER login from the application properties
            if session.role == USER:
20
                if not current.app.authorize_user_login:
21
                    session.role = None
22

23 24
        else:
            return 'The user role is not defined'
25 26

    # no login procedure
27
    else:
28
        session.role = ADMIN
29

30 31
    url = URL('plugin_dbui', 'index', args=request.args, vars=request.vars)
    return redirect(url)