一部のユーザーを特別なフォームにリダイレクトするログイン success_handler があります。いずれにせよ、AuthenticationSuccessHandlerInterface は Response を返す必要があり、1 つのケースを除いてうまく機能しています。ユーザーが最初に資格情報を間違って入力し、再度ログイン ページにリダイレクトされた場合、ハンドラーは、正しいログインの後に再度ログイン ページにリダイレクトします。
オプション use_referer: true を使用するだけで正しく動作します。したがって、イベントの代わりにコントローラーにロジックを配置することもできますが、おそらくあなたの誰かが私に解決策を持っています.
ありがとうございました
ファイアウォール
firewalls:
    main:
        pattern: ^/
        form_login:
            provider: fos_userbundle
            csrf_provider: form.csrf_provider
            success_handler: applypie_userbundle.login.handler
            #default_target_path: applypie_user_dashboard
            use_referer: true
        logout:       true
        anonymous:    true
イベント
namespace Applypie\Bundle\UserBundle\EventListener;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\HttpFoundation\Request;
class NewUserListener implements AuthenticationSuccessHandlerInterface
{
    protected $router;
    public function __construct(RouterInterface $router)
    {
        $this->router = $router;
    }
    public function onAuthenticationSuccess(Request $request, TokenInterface $token)
    {
        $user = $token->getUser();
        if(!$user->getApplicant() && !count($user->getCompanies())) {
            return new RedirectResponse($this->router->generate('applypie_user_applicant_create'));
        }
            return new RedirectResponse($request->headers->get('referer'));
    }
}
サービス
applypie_userbundle.login.handler:
    class: Applypie\Bundle\UserBundle\EventListener\NewUserListener
    arguments: ["@router"]