From 66b5713296e7bd9caabe8dd84bde644435b7712a Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Wed, 25 Oct 2023 10:37:35 +0300 Subject: [PATCH] Properly set session value for services_region Currently, the value stored in the services_region cookie is ignored when logging into horizon. This causes confusion for users that have previously selected one region, to find themselves in a different region after their token expires and are forced to log in again. This change sets the services_region session value to the value present in the cookie, with a fallback to the login region. Closes-bug: #2040455 Change-Id: I051648844bf8dffce792ff553e9949285b1be6d4 Signed-off-by: Gabriel Adrian Samfira --- openstack_auth/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openstack_auth/views.py b/openstack_auth/views.py index 0c5c2b3638..55fc9b2fb2 100644 --- a/openstack_auth/views.py +++ b/openstack_auth/views.py @@ -192,6 +192,10 @@ def login(request): region_name = regions.get(login_region) request.session['region_endpoint'] = region request.session['region_name'] = region_name + # Check for a services_region cookie. Fall back to the login_region. + services_region = request.COOKIES.get('services_region', region_name) + if services_region in request.user.available_services_regions: + request.session['services_region'] = services_region expiration_time = request.user.time_until_expiration() threshold_days = settings.PASSWORD_EXPIRES_WARNING_THRESHOLD_DAYS if (expiration_time is not None and