我在我们公司中使用odoo作为系统,并希望使用该网站获取内部新闻和信息。但是,公众不应看到该网站-只有登录的用户可以看到!未登录的观看者应重定向到登录屏幕。
那有可能吗,我该怎么办?
答案 0 :(得分:1)
使用@ http.route定义路由时,您将在其中定义参数“ auth”。从odoo文档中:
auth –
The type of authentication method, can on of the following:
user: The user must be authenticated and the current request will perform using the rights of the user.
public: The user may or may not be authenticated. If she isn’t, the current request will perform using the shared Public user.
none: The method is always active, even if there is no database. Mainly used by the framework and authentication modules. There request code will not have any facilities to access the database nor have any configuration indicating the current database nor the current user.
看看https://www.odoo.com/documentation/12.0/reference/http.html
答案 1 :(得分:1)
这很简单,只需在控制器的main.py文件中的方法中提供 auth =“ user” 。
@http.route('/name', type='http', csrf=False, auth='user', website=True)