By default, the form will redirect to the URL the user requested (i.e. the URL which triggered the login form being shown). For example, if the user requestedhttp://www.example.com/admin/post/18/edit
, then after they have successfully logged in, they will be sent back tohttp://www.example.com/admin/post/18/edit.
Redirecting after Success¶
always_use_default_target_path
: public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
{
if ($targetPath = $this->getTargetPath($request->getSession(), $providerKey)) {
return new RedirectResponse($targetPath);
}
return new RedirectResponse($this->router->generate('app_homepage'));
}