Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
4927 Zobrazení

Hello fellas here is my question:
Is possible to restrict access to given http route by res.groups.

Avatar
Zrušit
Nejlepší odpověď

Hi,

Inside the route you can check whether user belongs to some group or not. Based on this checking you can perform your operations,

See a sample,

@http.route(['/test/page'], type='http', csrf=False, auth="user", website=True)
def redirect_test_page(self, **kwargs):
    user_rec = request.env['res.users'].sudo().search([('id', '=', request.session.uid)])
    if user_rec.has_group('group_external_id'):
        # write the code if user belongs to group
        return request.render('template_id')
    else:
        # code here if user not in group
        return request.render('template_id')

Hope this will give you some idea.

Thanks

Avatar
Zrušit
Autor Nejlepší odpověď

Thank you this is what i needed! :)

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
zář 21
3687
0
lis 23
1269
1
úno 21
4789
4
čvc 20
13743
0
bře 18
4051