From 72c62982529394260b85bc4786741904e5d5911f Mon Sep 17 00:00:00 2001 From: jrockwei Date: Tue, 27 Apr 2021 09:54:20 -0500 Subject: [PATCH] IN-200 Users logged out while using PROD --- .../simplesamlphp_auth.settings.yml | 4 +- .../custom/epa_intranet/epa_intranet.theme | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/config/production/simplesamlphp_auth.settings.yml b/config/production/simplesamlphp_auth.settings.yml index ccc6798b2..656d1dfb2 100644 --- a/config/production/simplesamlphp_auth.settings.yml +++ b/config/production/simplesamlphp_auth.settings.yml @@ -13,9 +13,9 @@ role: register_users: true allow: set_drupal_pwd: false - default_login: false + default_login: true default_login_roles: - administrator: administrator + administrator: authenticated default_login_users: '1' logout_goto_url: 'https://work.epa.gov' user_register_original: null diff --git a/docroot/themes/custom/epa_intranet/epa_intranet.theme b/docroot/themes/custom/epa_intranet/epa_intranet.theme index 2817b6258..f5f7150a7 100644 --- a/docroot/themes/custom/epa_intranet/epa_intranet.theme +++ b/docroot/themes/custom/epa_intranet/epa_intranet.theme @@ -1,5 +1,7 @@ addCacheableDependency($variables, \Drupal::service('path.current')->getPath()); + foreach ($variables['items'] as &$key) { + $url = $key['url']; + if ($url->isRouted() && in_array($url->getRouteName(), $routes)) { + $base = \Drupal::request()->getSchemeAndHttpHost(); + // Get current path. + $current = \Drupal::service('path.current')->getPath(); + if ($url->getRouteName() == 'user.login') { + + $productionSplitConfig = \Drupal::config('config_split.config_split.production_config'); + // Check if we are in Production + if (isset($productionSplitConfig) && $productionSplitConfig->get('status')) { + //@todo update /saml_login to use the path from route: simplesamlphp_auth.saml_login + $uriString = $base . '/saml_login?destination=' . $current; + } else { + $uriString = $base . '/user/login?destination=' . $current; + } + } else { + $uriString = $base . '/user/logout?destination=' . $current; + } + $newUrl = Url::fromUri($uriString); + $key['url'] = $newUrl; + } + } +} + + function epa_intranet_preprocess_page(&$variables) { // Load correct Hero revision for page if (isset($variables['node'])) {