FriendsOfSymfony / FOSFacebookBundle

NOT MAINTAINED - see https://github.com/hwi/HWIOAuthBundle
322 stars 140 forks source link

Failing to integrate with custom entity provider #251

Closed klaussilveira closed 11 years ago

klaussilveira commented 11 years ago

I have a custom entity provider, formed by a custom User entity class and a UserRepository that extends the EntityRepository class.

I also have a FacebookProvider based on the one available here. It's modified to communicate with my UserRepository.

They're all registered as such:

security:
    providers:
        chain_provider:
            chain:
                providers: [main, fb_provider]
        main:
            entity: { class: AcmeBundle:User, property: username }
        fb_provider:
            id: facebook_user_provider

    firewalls:
        main:
            pattern:    ^/
            form_login:
                provider: main
            logout:     true
            anonymous:  true
            fos_facebook:
                app_url: "http://apps.facebook.com/acme/"
                server_url: "http://acme.dev/app_dev.php/"
                provider: fb_provider

Problem is: i want users to login using the normal login form, using the UserRepository, instead of Facebook. Facebook is now used everywhere, intercepting the normal login form, instead of issuing proper default User AuthorizationTokens.

"The Facebook user could not be retrieved from the session." is shown, since i'm not using the correct provider. How can i work with multiple providers? A Facebook provider for FB logins and my Entity Provider for normal logins?

diegoholiveira commented 11 years ago

try to add check_path to your provider configuration, as above:

security:
    providers:
        chain_provider:
            chain:
                providers: [main, fb_provider]
        main:
            entity: { class: AcmeBundle:User, property: username }
        fb_provider:
            id: facebook_user_provider

    firewalls:
        main:
            pattern:    ^/
            form_login:
                check_path: /login-check
                provider: main
            logout:     true
            anonymous:  true
            fos_facebook:
                check_path: /login-check-fb
                app_url: "http://apps.facebook.com/acme/"
                server_url: "http://acme.dev/app_dev.php/"
                provider: fb_provider

I guess it will trigger the rigth provider.

peltho commented 11 years ago

@klaussilveira, I'm currently running into the same issue. Could it be possible to share me your FacebookProvider ? I decided to create my own User Provider and i'm wondering if I have to replace the user manager argument needed by the FacebookProvider to my UserRepository. I'm sorry for my poor english.