bon j'ai avancé un peu, il faudrait utiliser une classe qui implemente AuthenticationSuccessHandlerInterface
Du coup j'ai créé ma classe dans ACME/UserBundle/Handler/AuthenticationHandler.php :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| <?php
namespace ACME\UserBundle\Handler;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
class AuthenticationHandler implements AuthenticationSuccessHandlerInterface
{
function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
$logger = $this->get('logger');
$logger->info('auth success');
return new RedirectResponse($this->container->get('router')->generate('login_success'));
}
} |
Dans ACME/UserBundle/Ressources/config/services.yml j'ai mis
1 2 3
| services:
authenticationhandler:
class: ACME\UserBundle\Handler\AuthenticationHandler |
Et enfin dans mon app/config/security.yml j'ai mis
1 2 3 4 5 6
| form_login:
provider: fos_userbundle
login_path: fos_user_security_login
check_path: fos_user_security_check
default_target_path: acme_user_index
success_handler: authenticationhandler |
Quand je vais sur ma page il me dit :
ServiceNotFoundException: The service "security.firewall.map.context.secured_area" has a dependency on a non-existent service "authenticationhandler".
Pourquoi il ne trouve pas mon service ?
Merci.
Partager