После того, как пользователь сбросил свой пароль, используя сброс пароля FOSUserBundle, по умолчанию он перенаправляется в FOSUserProfile. Я хочу перенаправить на другой маршрут в соответствии с их ролью. Возможно ли это, и если да, то как? я этот код, но он перенаправляет все виды пользователейFOSUserBundle: цель успеха после сброса пароля в соответствии с ролями
namespace Acme\UserBundle\EventListener;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Event\FormEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* Listener responsible to change the redirection at the end of the password resetting
*/
class PasswordResettingListener implements EventSubscriberInterface {
private $router;
public function __construct(UrlGeneratorInterface $router) {
$this->router = $router;
}
public static function getSubscribedEvents() {
return [
FOSUserEvents::RESETTING_RESET_SUCCESS => 'onPasswordResettingSuccess',
];
}
public function onPasswordResettingSuccess(FormEvent $event) {
$url = $this->router->generate('homepage');
$event->setResponse(new RedirectResponse($url));
}
}
А потом я его регистрации в качестве службы с
services:
acme_user.password_resetting:
class: Acme\UserBundle\EventListener\PasswordResettingListener
arguments: [ "@router" ]
tags:
- { name: kernel.event_subscriber }
http://symfony.com/blog/new-in-symfony-2-6-security-component-improvements – pavlovich