Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
4664 Vues

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

Avatar
Ignorer
Meilleure réponse

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
Ignorer
Auteur Meilleure réponse

Thank you this is what i needed! :)

Avatar
Ignorer
Publications associées Réponses Vues Activité
2
sept. 21
3367
0
nov. 23
976
1
févr. 21
4353
4
juil. 20
13371
0
mars 18
3670