Manual authenticate user

前端 未结 2 479
暖寄归人
暖寄归人 2020-12-16 15:53

I try to authenticate user:

getDoctr         


        
相关标签:
2条回答
  • 2020-12-16 16:30

    Try code from this answer. In your case firewall name is secured_area:

    // your controller action
    public function myAction()
    {
    
        // Authenticating user
        $token = new UsernamePasswordToken($user, null, 'secured_area', $user->getRoles());
        $this->get('security.token_storage')->setToken($token);
        //For Symfony <= 2.3
        //$this->get('security.context')->setToken($token);
        $this->get('session')->set('_security_secured_area', serialize($token));
    
    }
    
    0 讨论(0)
  • 2020-12-16 16:39

    Verify that you have configured encoders section in security.yml, as configuration there has changed not very long time ago and it affects your problem.

    0 讨论(0)
提交回复
热议问题