我想在授权成功后重定向用户更改密码表单,我收到此错误: OutOfBoundsException:索引“1”不在[0,0]范围内。
namespace Infogold\KonsultantBundle\Service;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\RouterInterface;
/**
* Custom authentication success handler
*/
class AuthenticationSuccessHandler implements AuthenticationSuccessHandlerInterface
{
protected $router;
/**
* Constructor
* @param RouterInterface $router
*/
public function __construct(RouterInterface $router)
{
$this->router = $router;
}
function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
.
.
.
我的服务
parameters:
security.authentication.success_handler.class: Infogold\KonsultantBundle\Service\AuthenticationSuccessHandler
services:
security.authentication.success_handler:
class: %security.authentication.success_handler.class%
arguments: ['@router']
和两个防火墙的安全性,首先是我的防火墙,第二个来自FOSuserBundle:
firewalls:
konsultant_area:
pattern: ^/konsultant
context: my_context1
anonymous: true
form_login:
provider: administrators
use_forward: true
login_path: /konsultant/login
check_path: /konsultant/login_check
post_only: true
always_use_default_target_path: true
default_target_path: /konsultant/klient/indywidualni
use_referer: false
success_handler: security.authentication.success_handler
failure_path: /konsultant/login
failure_forward: false
username_parameter: _username
password_parameter: _password
logout: true
main:
pattern: ^/
context: my_context2
.
.
.
答案 0 :(得分:0)
我解决了我的问题。对于发生此错误的人: 我用
中的下划线替换了点success_handler: security.authentication.success_handler
success_handler: security_authentication_success_handler
和服务:
parameters:
security_authentication_success_handler.class: Infogold\KonsultantBundle\Service\AuthenticationSuccessHandler
services:
security_authentication_success_handler:
class: %security_authentication_success_handler.class%
public: false
arguments: ['@router']
现在一切都好了。