Answer the question
In order to leave comments, you need to log in
What is the best way to implement a redirect if the user is authorized in Symfony?
/**
* @param AuthenticationUtils $authenticationUtils
* @Route("/login", name="app_login")
* @return Response
*/
public function login(AuthenticationUtils $authenticationUtils): Response
{
//Хотел бы убрать эту часть
if($user = $this->getUser()) {
return $this->redirectToRoute('dashboard');
}
return $this->render('security/login.html.twig', ['last_username' => $authenticationUtils->getLastUsername(), 'error' => $authenticationUtils->getLastAuthenticationError()]);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question