File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Kernel/Listener/ExceptionListener Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -73,8 +73,9 @@ public function __invoke(Request $request): Response
73
73
$ route = $ go_to_create_ticket ? "/ServiceCatalog " : "/Helpdesk " ;
74
74
$ redirect = $ request ->getBasePath () . $ route ;
75
75
} else {
76
- $ _SESSION ['_redirected_from_profile_selector ' ] = true ;
77
76
$ redirect = Html::getBackUrl ();
77
+ $ separator = str_contains ($ redirect , '? ' ) ? "& " : "? " ;
78
+ $ redirect = $ redirect . $ separator . '_redirected_from_profile_selector=true ' ;
78
79
}
79
80
80
81
return new RedirectResponse ($ redirect );
Original file line number Diff line number Diff line change @@ -72,6 +72,13 @@ public function onKernelException(ExceptionEvent $event): void
72
72
73
73
$ response = null ;
74
74
75
+ // On profile change, we will redirect the user to the home page in case
76
+ // of access errors for the current page.
77
+ $ redirect_to_home_on_error = $ event ->getRequest ()
78
+ ->query
79
+ ->getBoolean ('_redirected_from_profile_selector ' )
80
+ ;
81
+
75
82
if ($ throwable instanceof SessionExpiredException) {
76
83
Session::destroy (); // destroy the session to prevent pesistence of unexpected data
77
84
@@ -84,10 +91,8 @@ public function onKernelException(ExceptionEvent $event): void
84
91
);
85
92
} elseif (
86
93
$ throwable instanceof AccessDeniedHttpException
87
- && ( $ _SESSION [ ' _redirected_from_profile_selector ' ] ?? false )
94
+ && $ redirect_to_home_on_error
88
95
) {
89
- unset($ _SESSION ['_redirected_from_profile_selector ' ]);
90
-
91
96
$ request = $ event ->getRequest ();
92
97
$ response = new RedirectResponse (
93
98
sprintf (
You can’t perform that action at this time.
0 commit comments