admin.py 804 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 = list(session.auth.user_groups.values())
14

15
        if len(roles) > 0:
16
            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
        else:
LE GAC Renaud's avatar
LE GAC Renaud committed
24
            return "The user role is not defined"
25 26

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

LE GAC Renaud's avatar
LE GAC Renaud committed
30
    url = URL("plugin_dbui", "index", args=request.args, vars=request.vars)
31
    return redirect(url)