Merge "Distributed Cloud fix for switching between RegionOne and SystemController"
This commit is contained in:
commit
b057924b79
@ -68,6 +68,9 @@ if distributed_cloud_role and distributed_cloud_role in ['systemcontroller',
|
|||||||
'subcloud']:
|
'subcloud']:
|
||||||
DC_MODE = True
|
DC_MODE = True
|
||||||
|
|
||||||
|
HORIZON_CONFIG["user_home"] = \
|
||||||
|
"starlingx_dashboard.utils.settings.get_user_home"
|
||||||
|
|
||||||
OPENSTACK_ENDPOINT_TYPE = "internalURL"
|
OPENSTACK_ENDPOINT_TYPE = "internalURL"
|
||||||
|
|
||||||
# Override Django tempory file upload directory
|
# Override Django tempory file upload directory
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2019 Wind River Systems, Inc.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
horizon.addInitFunction(function () {
|
||||||
|
// This is a workaround to automatically redirect to the login page when an authorization error page is displayed.
|
||||||
|
// It occurs every time a user switches between RegionOne and SystemController in a distributed cloud setup
|
||||||
|
// since the same dashboards are not accessible to both regions.
|
||||||
|
// The login page will see the user is already logged in and redirect to the user's home page.
|
||||||
|
if ($("#content_body:contains('You are not authorized to access this page')").length > 0){
|
||||||
|
window.location.replace("/auth/login/")
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,35 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2019 Wind River Systems, Inc.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
import horizon
|
||||||
|
from horizon import base
|
||||||
|
|
||||||
|
|
||||||
|
def get_user_home(user):
|
||||||
|
dashboard = horizon.get_default_dashboard()
|
||||||
|
dc_mode = getattr(settings, 'DC_MODE', False)
|
||||||
|
|
||||||
|
if user.is_superuser:
|
||||||
|
if getattr(user, 'services_region', None) == 'SystemController':
|
||||||
|
try:
|
||||||
|
dashboard = horizon.get_dashboard('dc_admin')
|
||||||
|
except base.NotRegistered:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if getattr(user, 'services_region', None) == 'RegionOne' and dc_mode:
|
||||||
|
try:
|
||||||
|
if user.is_superuser:
|
||||||
|
dashboard = horizon.get_dashboard('admin'). \
|
||||||
|
get_panel("inventory")
|
||||||
|
else:
|
||||||
|
dashboard = horizon.get_dashboard('project'). \
|
||||||
|
get_panel("api_access")
|
||||||
|
except base.NotRegistered:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return dashboard.get_absolute_url()
|
Loading…
x
Reference in New Issue
Block a user