Hi everyone and huge thanks for the help, I am trying to get FOSFacebook work, but it seems to be impossible until now. I tried a lot of configuration, and a lot of fix but nothing worked for me.
Here is my configuration :
security.yml
chain_provider:
chain:
providers: [fos_userbundle, fos_facebook_provider]
fos_userbundle:
id: fos_user.user_provider.username
fos_facebook_provider:
id: fos.facebook.custom_provider
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
form_login:
login_path: fos_user_security_login
check_path: fos_user_security_check
provider: fos_userbundle
csrf_provider: form.csrf_provider
logout: true
anonymous: true
public:
pattern: ^/
fos_facebook:
app_url: "http://apps.facebook.com/myApp/"
server_url: "http://www.mywebsite.com"
login_path: /facebook/login
check_path: /facebook/check
default_target_path: /
provider: fos_facebook_provider
anonymous: false
logout:
handlers: ["fos_facebook.logout_handler"]
config.yml
fos.facebook.custom_provider:
class: Bundles\UserBundle\Security\User\Provider\FacebookProvider
arguments:
facebook: "@fos_facebook.api"
userManager: "@fos_user.user_manager"
validator: "@validator"
container: "@service_container"
fos_facebook:
file: %kernel.root_dir%/../vendor/facebook/php-sdk/src/base_facebook.php
alias: facebook
app_id: myid
secret: mysecret
cookie: true
permissions: [email]
routing.yml
_security_check:
pattern: /facebook/check
_security_logout:
pattern: /logout
Twig Template
<script type="text/javascript">
function goLogIn(){
window.location.href = "{{ path('_security_check') }}";
}
function onFbInit() {
if (typeof(FB) != 'undefined' && FB != null ) {
FB.Event.subscribe('auth.statusChange', function(response) {
if (response.session || response.authResponse) {
setTimeout(goLogIn, 500);
} else {
window.location.href = "{{ path('_security_logout') }}";
}
});
}
}
</script>
{{ facebook_initialize({'xfbml': true, 'fbAsyncInit': 'onFbInit();'}) }}
UserController.php
* @Route("/facebook/check")
*/
public function loginCheckFacebookAction(){
}
And the provider and the modification to User class (as in the Readme).
But the problem is that the service not seemed to be called. Indeed, the method in the UserController must be a dummy method, and it is not like that here. The method is called and of course I get this error :
LogicException: The controller must return a response (null given). Did you forget to add a return statement somewhere in your controller? (uncaught exception).
What is my error here ?