I want to login a user after registration successfully. Currently the solution I found online is login a user in a session basis. But I need the "remember me" feature. My research lead me to the
Symfony\Component\Security\Http\RememberMe\TokenBasedRememberMeServices
and its function
onLoginSuccess
But I'm out of luck and end up with circular reference detected for service. Also the onLoginSuccess is protected function. I assume I can duplicate those functions in my own function where performing a login feature. But that's always not a good choice. So I'd like to learn if anyone had experience on that?
Here I had my own answer. First, login user with following snippet
Be aware that your own userProvider or EndUser maybe different from mine. Change the $user accordingly to make it work in your own situation.
Second, implement the remember me feature.
Some explanation here. Above code is firstly fetch remember me configuration for security.yml which is needed to initiate TokenBasedRememberMeServices instance. Then use the ReflectionMethod to overcome the accessible issue because method onLoginSuccess is originally protected.
This solution is tested under symfony 3.3.16. Hope this help others.