How to configure a remember me aware listener in Symfony 2?

前端 未结 5 583
既然无缘
既然无缘 2021-02-14 23:25

I have implemented a custom authentication provider successfully, but now I also need to add \'remember me\' functionality, and I couldn\'t find docs on how to do that.

5条回答
  •  执念已碎
    2021-02-14 23:48

    In my case it happened when i create a Factory class implementing SecurityFactoryInterface (as it was described in example "How to Create a custom Authentication Provider"). Later i found that another way to create this Factory is extending from AbstractFactory which contains neccessary readme stuff (you can find it create() method). So there are two solutions: 1) extend AbstractFactory instead of implementing SecurityFactoryInterface 2) implement SecurityFactoryInterface and copypaste readme related code. In symfony 3.1:

           // add remember-me aware tag if requested
        if ($this->isRememberMeAware($config)) {
            $container
                ->getDefinition($listenerId)
                ->addTag('security.remember_me_aware', array('id' => $id, 'provider' => $userProviderId))
            ;
        }
    

提交回复
热议问题