You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following an upgrade from Symfony 4.4.41 to 4.4.42 I seem to be unable to use 'target' in the following way:
/**
* Attempting to login as the specified user.
*
* @Route(
* "/login",
* name = "crmpicco_login"
* )
* @Template("@App/Register/login.html.twig")
*
* @param Request $request
* @param LoginHelper $loginHelper
*
* @return array
*/
public function loginAction(Request $request, LoginHelper $loginHelper): array
{
return $this->loginHelper($request, $loginHelper);
}
/**
* @param Request $request
* @param LoginHelper $loginHelper
*
* @return array
*/
protected function loginHelper(Request $request, LoginHelper $loginHelper): array
{
/* @var $session \Symfony\Component\HttpFoundation\Session\Session */
$session = $request->getSession();
// get the error if any (works with forward and redirect -- see below)
if ($request->attributes->has(LoginSecurity::AUTHENTICATION_ERROR)) {
$error = $request->attributes->get(LoginSecurity::AUTHENTICATION_ERROR);
} elseif (null !== $session && $session->has(LoginSecurity::AUTHENTICATION_ERROR)) {
$error = $session->get(LoginSecurity::AUTHENTICATION_ERROR);
$session->remove(LoginSecurity::AUTHENTICATION_ERROR);
} else {
$error = '';
}
$csrfToken = $this->getContainerInterface()->get('security.csrf.token_manager')->getToken('authenticate');
return [
'error' => $error,
'csrf_token' => $csrfToken,
'target' => 'crmpicco_register_details',
];
}
I can see there were some changes to the DefaultAuthenticationSuccessHandlerin 4.4.42, however it's unclear how to fix this in my application.
My SuccessHandler looks like this:
public function onAuthenticationSuccess(Request $request, TokenInterface $token): RedirectResponse
{
return $this->httpUtils->createRedirectResponse($request, $this->determineTargetUrl($request));
}
What I am experiencing is the redirect is not respecting the "crmpicco_register_details" route I am passing through and is instead redirecting to the default "admin" route on successful login.
How do I remedy this in my application? (For now, i've reverted to 4.4.41 until I can fix this).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Following an upgrade from Symfony 4.4.41 to 4.4.42 I seem to be unable to use 'target' in the following way:
I can see there were some changes to the
DefaultAuthenticationSuccessHandler
in 4.4.42, however it's unclear how to fix this in my application.My
SuccessHandler
looks like this:What I am experiencing is the redirect is not respecting the "crmpicco_register_details" route I am passing through and is instead redirecting to the default "admin" route on successful login.
How do I remedy this in my application? (For now, i've reverted to 4.4.41 until I can fix this).
Is this likely to be related to #46317 ?
Beta Was this translation helpful? Give feedback.
All reactions