Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
4679 Vizualizări

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

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Autor Cel mai bun răspuns

Thank you this is what i needed! :)

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
sept. 21
3393
0
nov. 23
1003
1
feb. 21
4368
4
iul. 20
13376
0
mar. 18
3679