Skip to content

Commit

Permalink
PUBLIQ-635: Fix the fallback to 'authenticated'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nils Destoop committed Aug 3, 2022
1 parent bf59888 commit f1b9e1f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion includes/theme.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
14 changes: 8 additions & 6 deletions src/Controller/AuthenticationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion uitid.module
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Implements hook_theme().
*/
function uitid_user_theme() {
function uitid_theme() {
$theme = [];

$theme['uitid_authenticated_page'] = [
Expand Down

0 comments on commit f1b9e1f

Please sign in to comment.