diff --git a/services/drupal/web/modules/custom/f1_sso/f1_sso.module b/services/drupal/web/modules/custom/f1_sso/f1_sso.module index a9804506b..ea4f8c318 100644 --- a/services/drupal/web/modules/custom/f1_sso/f1_sso.module +++ b/services/drupal/web/modules/custom/f1_sso/f1_sso.module @@ -20,7 +20,20 @@ function f1_sso_user_login($account) { // Only overwrite destination if we don't already have one set. if (empty(\Drupal::service('request_stack')->getCurrentRequest()->query->get('destination'))) { - \Drupal::service('request_stack')->getCurrentRequest()->query->set('destination', '/admin/content/my-web-areas'); + $url = \Drupal\Core\Url::fromUserInput('/admin/content/my-web-areas'); + + //Generate absolute URL, setting to TRUE collect bubbleable metadata + $generatedUrl = $url->toString(TRUE); + + $cacheability = new Drupal\Core\Cache\CacheableMetadata(); + $cacheability->setCacheContexts(['user.roles', 'url.query_args']); + + $response = new Drupal\Core\Routing\TrustedRedirectResponse($generatedUrl->getGeneratedUrl()); + $response->addCacheableDependency($cacheability); + + + \Drupal::request()->query->set('destination', $generatedUrl->getGeneratedUrl()); + \Drupal::service('request_stack')->getCurrentRequest()->attributes->set('_redirect', $response); } }