1
votes

In my Symfony 2.6 website I have a login form that works. I'm now working on a registration/authentication based on Facebook SDK.

On the Facebook side, I have no problems, the user local account is created and the login works.

But, when I programmatically authenticate a Facebook-registered user (just after its first registration), Symfony says in the debug toolbar that the user is logged, but not authenticated:

fig1

If the user logouts, then login again (but not using the Symfony form, but still my system), it is full-authenticated:

fig2

Here the code I use to authenticate the Facebook user:

$token = new UsernamePasswordToken($user, $user->getPassword(), 'main', $user->getRoles());
$this->get('security.token_storage')->setToken($token);

This code is used to authenticate Facebook users, at their registration and also on login. What are the consequences if the user is not fully authenticated? And how to fully-authenticate the user at the first registration?

Here my authentication method on Pastebin : http://pastebin.com/d5T2umGx

1
After setting the token do you refresh the page and then check to see if they are logged in/authenticated?Jason Roman
Yep, the page is reloaded and the user is not authenticated until it logins again.Morgan Touverey Quilling

1 Answers

0
votes

it looks like you may've forgotten to dispatch a login event.

//now dispatch the login event
$event = new InteractiveLoginEvent($request, $token);
$this->get("event_dispatcher")->dispatch("security.interactive_login", $event);