default.py 1.13 KB
Newer Older
1 2
# -*- coding: utf-8 -*-
""" Controllers
3

4
"""
5 6 7
from plugin_event import ADMIN


LE GAC Renaud's avatar
LE GAC Renaud committed
8
@auth.requires(True, requires_login=not request.is_local)
9 10 11 12
def index():
    """Main Controller to run the application launching the plugin dbui.

    """
13 14
    # login procedure is active
    if session.auth:
LE GAC Renaud's avatar
LE GAC Renaud committed
15
        roles = session.auth.user_groups.values()
LE GAC Renaud's avatar
LE GAC Renaud committed
16

17 18
        if roles:
            session.role = roles[0]
LE GAC Renaud's avatar
LE GAC Renaud committed
19

20 21
        else:
            return 'The user role is not defined'
LE GAC Renaud's avatar
LE GAC Renaud committed
22 23

    # no login procedure
LE GAC Renaud's avatar
LE GAC Renaud committed
24
    else:
25
        session.role = ADMIN
LE GAC Renaud's avatar
LE GAC Renaud committed
26

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


LE GAC Renaud's avatar
LE GAC Renaud committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44
def user():
    """exposes:
    http://..../[app]/default/user/login
    http://..../[app]/default/user/logout
    http://..../[app]/default/user/register
    http://..../[app]/default/user/profile
    http://..../[app]/default/user/retrieve_password
    http://..../[app]/default/user/change_password
    use @auth.requires_login()
        @auth.requires_membership('group name')
        @auth.requires_permission('read','table name',record_id)
    to decorate functions that need access control
    """
    return dict(form=auth())