diff --git a/includes/theme.inc b/includes/theme.inc index b51dbe8..f8e5831 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -14,6 +14,6 @@ use Drupal\Core\Url; * Array of currently known variables. */ function template_preprocess_uitid_authenticated_page(array &$variables) { - $variables['connect_url'] = Url::fromRoute('uitid.connect'); + $variables['connect_url'] = Url::fromRoute('uitid.connect', [], ['query' => Drupal::destination()->getAsArray()]); $variables['login_message'] = t('You should be logged in to proceed.'); } diff --git a/src/Controller/AuthenticationController.php b/src/Controller/AuthenticationController.php index 6fa3701..23cc294 100644 --- a/src/Controller/AuthenticationController.php +++ b/src/Controller/AuthenticationController.php @@ -85,21 +85,23 @@ public static function create(ContainerInterface $container) { */ public function login(Request $request) { $params = [ - Auth0::TRANSIENT_STATE_KEY => base64_encode( - \json_encode($this->getDestinationArray()), - ), 'prompt' => 'login' ]; + if ($request->query->has('destination')) { + $params[Auth0::TRANSIENT_STATE_KEY] = base64_encode( + \json_encode($this->getDestinationArray()), + ); + // Remove the destination query parameter, so Drupal does not interfere with our redirect response. + $request->query->remove('destination'); + } + if ($referrer = $this->config(UitIdSettingsForm::CONFIG_NAME)->get('referrer')) { $params['referrer'] = $referrer; } $redirect = new TrustedRedirectResponse($this->auth0Client->getLoginUrl($params), 302); - // Remove the destination query parameter, so Drupal does not interfere with our redirect response. - $request->query->remove('destination'); - $metadata = $redirect->getCacheableMetadata(); $metadata->setCacheMaxAge(0); diff --git a/uitid.module b/uitid.module index 63307c2..9a65442 100644 --- a/uitid.module +++ b/uitid.module @@ -8,7 +8,7 @@ /** * Implements hook_theme(). */ -function uitid_user_theme() { +function uitid_theme() { $theme = []; $theme['uitid_authenticated_page'] = [