Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
4659 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thank you this is what i needed! :)

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ย. 21
3364
0
พ.ย. 23
974
1
ก.พ. 21
4353
4
ก.ค. 20
13371
0
มี.ค. 18
3670