Skip to Content
Menu
This question has been flagged
2 Replies
3810 Views

Hello,

I need to create private web pages. Then these pages have to be accessible only if user is connected. I do not find modules, but I must be wrong. Do you have any ressource to help me ?


Thanks

Avatar
Discard
Best Answer

 Else, if you want do it just for page form controller /page/xxx you can use the html editor (not user friendly) and add manually a groups="base.group_user" on your top html node.

(and manage the case where not in group to redirect or display a message)

Avatar
Discard

isn't it groups="base.group_user"? also, never tested it, but I think you can set in on the view itself (ir.ui.view)

oups, just updated my answer ! thank you for the reporting :)

Best Answer

Hi @smorele

For that you just need to define a controller method for your url and decorate it passing the param auth with the value "user", like this Odoo example modified for that:

@http.route(['/robots.txt'], type='http', auth="user")

def robots(self):

return request.render('website.robots', {'url_root': request.httprequest.url_root}, mimetype='text/plain')

Avatar
Discard
Author

it's more complicated, I have to add dynamically this parameter function of page.

Also you could have one controller method url that it's decorated with auth="user" and redirect to that url if your page does not meet some requirement or condition. Like
return werkzeug.utils.redirect(url)