From 7378e519a25642489494f49138f28b8dcbafa100 Mon Sep 17 00:00:00 2001 From: Mike Decker Date: Fri, 20 Oct 2023 10:49:23 -0700 Subject: [PATCH] Fix site setting redirect logic --- src/EventSubscriber/EventSubscriber.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/EventSubscriber/EventSubscriber.php b/src/EventSubscriber/EventSubscriber.php index 9dd576fd..b7d75c62 100644 --- a/src/EventSubscriber/EventSubscriber.php +++ b/src/EventSubscriber/EventSubscriber.php @@ -136,13 +136,17 @@ public function onKernelRequest(RequestEvent $event) { protected static function redirectUser() { $current_user = \Drupal::currentUser(); $cache = \Drupal::cache(); - if ($cache_data = $cache->get('su_renew_site:' . $current_user->id())) { - return $cache_data->data; - } /** @var \Drupal\Core\Routing\CurrentRouteMatch $route_match */ $route_match = \Drupal::service('current_route_match'); $name = $route_match->getCurrentRouteMatch()->getRouteName(); + if (in_array($name, ['system.css_asset', 'system.js_asset'])) { + return FALSE; + } + + if ($cache_data = $cache->get('su_renew_site:' . $current_user->id())) { + return $cache_data->data; + } /** @var \Drupal\config_pages\ConfigPagesLoaderServiceInterface $config_page_loader */ $config_page_loader = \Drupal::service('config_pages.loader'); @@ -153,9 +157,8 @@ protected static function redirectUser() { $site_manager = $current_user->hasPermission('edit stanford_basic_site_settings config page entity') && !in_array('administrator', $current_user->getRoles()); - $ignore_routes = ['system.css_asset', 'system.js_asset']; // If the renewal date has passed, they should be redirected. - $needs_renewal = !in_array($name, $ignore_routes) && !getenv('CI') && $site_manager && (strtotime($renewal_date) - time() < 60 * 60 * 24); + $needs_renewal = !getenv('CI') && $site_manager && (strtotime($renewal_date) - time() < 60 * 60 * 24); $cache->set('su_renew_site:' . $current_user->id(), $needs_renewal, time() + 60 * 60 * 24); return $needs_renewal;