website_search_products: fix redirect after login
This commit is contained in:
parent
9d69e5f095
commit
3c5809774f
1 changed files with 6 additions and 19 deletions
|
|
@ -38,23 +38,10 @@ class InventoryForm(http.Controller):
|
||||||
class WebsiteController(Website):
|
class WebsiteController(Website):
|
||||||
"""Extend Website controller to redirect portal users after login."""
|
"""Extend Website controller to redirect portal users after login."""
|
||||||
|
|
||||||
@http.route(website=True, auth="public")
|
def _login_redirect(self, uid, redirect=None):
|
||||||
def web_login(self, redirect=None, *args, **kw):
|
"""Send non-internal users to the website home instead of /my,
|
||||||
"""Handle login redirection based on user group."""
|
unless an explicit redirect was requested."""
|
||||||
response = super().web_login(redirect=redirect, *args, **kw)
|
|
||||||
|
|
||||||
# Check if login was successful
|
|
||||||
if not redirect and request.params.get("login_success"):
|
if not redirect and request.params.get("login_success"):
|
||||||
user = request.env["res.users"].browse(request.uid)
|
if not request.env["res.users"].browse(uid)._is_internal():
|
||||||
|
redirect = "/"
|
||||||
# Redirect internal users to web, others to inventory search
|
return super()._login_redirect(uid, redirect=redirect)
|
||||||
if user.has_group("base.group_user"):
|
|
||||||
# Keep original redirect for internal users
|
|
||||||
redirect_url = "/web"
|
|
||||||
else:
|
|
||||||
# Redirect portal users to inventory search
|
|
||||||
redirect_url = "/inventory/search"
|
|
||||||
|
|
||||||
return werkzeug_redirect(redirect_url)
|
|
||||||
|
|
||||||
return response
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue