From 3c5809774fd53ed45411ca3efd72ee271a9916d8 Mon Sep 17 00:00:00 2001 From: luis Date: Mon, 5 Oct 2026 18:34:47 +0200 Subject: [PATCH] website_search_products: fix redirect after login --- .../controllers/controller.py | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/website_search_products/controllers/controller.py b/website_search_products/controllers/controller.py index ed2d861..204850e 100644 --- a/website_search_products/controllers/controller.py +++ b/website_search_products/controllers/controller.py @@ -38,23 +38,10 @@ class InventoryForm(http.Controller): class WebsiteController(Website): """Extend Website controller to redirect portal users after login.""" - @http.route(website=True, auth="public") - def web_login(self, redirect=None, *args, **kw): - """Handle login redirection based on user group.""" - response = super().web_login(redirect=redirect, *args, **kw) - - # Check if login was successful + def _login_redirect(self, uid, redirect=None): + """Send non-internal users to the website home instead of /my, + unless an explicit redirect was requested.""" if not redirect and request.params.get("login_success"): - user = request.env["res.users"].browse(request.uid) - - # Redirect internal users to web, others to inventory search - 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 + if not request.env["res.users"].browse(uid)._is_internal(): + redirect = "/" + return super()._login_redirect(uid, redirect=redirect)