odoo:如何只显示登录用户的网站
odoo: How to only show logged in users the website
我在我们公司使用 odoo 作为一个系统,想使用该网站获取内部新闻和信息。但是 public 不应该看到该网站 - 只有登录用户才能看到!未登录的观众应该被重定向到登录屏幕。
这可能吗?我该怎么做?
当您使用@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
很简单,只需在控制器的 main.py 文件的方法中提供 auth="user"。
@http.route('/name', type='http', csrf=False, auth='user', website=True)
我在我们公司使用 odoo 作为一个系统,想使用该网站获取内部新闻和信息。但是 public 不应该看到该网站 - 只有登录用户才能看到!未登录的观众应该被重定向到登录屏幕。
这可能吗?我该怎么做?
当您使用@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
很简单,只需在控制器的 main.py 文件的方法中提供 auth="user"。
@http.route('/name', type='http', csrf=False, auth='user', website=True)