Skip to content

Commit 5c881f9

Browse files
committed
remove Controller and do redirect in the Event Subscriber
1 parent fa2cd9c commit 5c881f9

File tree

3 files changed

+10
-32
lines changed

3 files changed

+10
-32
lines changed

src/Controller/AccessDeniedController.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/EventSubscriber/AccessDeniedRedirectSubscriber.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Drupal\Core\Routing\UrlGeneratorInterface;
1111
use Symfony\Component\DependencyInjection\ContainerInterface;
1212
use Drupal\Core\Session\AccountInterface;
13+
use Drupal\Core\Url;
1314

1415
class AccessDeniedRedirectSubscriber implements EventSubscriberInterface {
1516

@@ -42,10 +43,16 @@ public function onKernelException(ExceptionEvent $event): void {
4243
return;
4344
}
4445

46+
4547
// Redirect other users to CWL Login
46-
//\Drupal::logger('UBC CWL')->debug('No CWL role... redirect');
47-
$url = $this->urlGenerator->generate('ubc_cwl_auth.ubc_cwl_redirect');
48-
$response = new RedirectResponse($url);
48+
$request = $event->getRequest();
49+
$source_page = $request->getRequestUri();
50+
51+
$redirect_url = Url::fromUri('internal:/saml/login', [
52+
'query' => ['destination' => $source_page],
53+
])->toString();
54+
55+
$response = new RedirectResponse($redirect_url);
4956
$event->setResponse($response);
5057
}
5158

ubc_cwl_auth.routing.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)