You have to implement an authentication handler class witch redirect you where you want in case of authentication success.
services.yml
parameters:
authentication_handler_class: Namespace\authenticationHandlerClass
services:
authentication_handler:
class: %authentication_handler_class%
arguments: [@router]
tags:
- { name: 'monolog.logger', channel: 'security' }
authenticationHandlerClass
<?php
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Bundle\FrameworkBundle\Routing\Router;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
class AuthenticationHandler implements AuthenticationSuccessHandlerInterface
{
private $router;
public function __construct(Router $router)
{
$this->router = $router;
}
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
$url = $this->router->generate('nameofmyroute');
return new RedirectResponse($url);
}
}