I am obligated to login in my web #116

Closed
opened 2026-01-24 11:36:09 +01:00 by admin · 7 comments
Owner

Originally created by @Chrysweel on GitHub (Oct 15, 2012).

This bundle works it. But I am obligated to login from my web.
I log in page of facebook, but when I visit my web, the button login knows that I am connected in facebook, because the button says "logout", but I can't access my page private with role ROLE_FACEBOOK.

I have to do logout in facebook and connect from my buttom facebook.

Why ??

Originally created by @Chrysweel on GitHub (Oct 15, 2012). This bundle works it. But I am obligated to login from my web. I log in page of facebook, but when I visit my web, the button login knows that I am connected in facebook, because the button says "logout", but I can't access my page private with role ROLE_FACEBOOK. I have to do logout in facebook and connect from my buttom facebook. Why ??
admin closed this issue 2026-01-24 11:36:09 +01:00
Author
Owner

@diegoholiveira commented on GitHub (Dec 28, 2012):

What is happen is that Facebook JS SDK knows that are you logged, but your symfony 2 application don't know notting about it. Force the user to be redirect to the check_path (defined on your security.yml).

@diegoholiveira commented on GitHub (Dec 28, 2012): What is happen is that Facebook JS SDK knows that are you logged, but your symfony 2 application don't know notting about it. Force the user to be redirect to the check_path (defined on your security.yml).
Author
Owner

@Chrysweel commented on GitHub (Jan 28, 2013):

@diegoholiveira
Thanks for to reply.
Still could not solve the problem.

This my security.yml

providers:
        chain_provider:
            chain:
                providers: [fos_userbundle, my_fos_facebook_provider]
        fos_userbundle:
            id: fos_user.user_provider.username_email
        my_fos_facebook_provider:
              id: my.facebook.user 
 firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        admin:
            switch_user: true
            context: user
            pattern: /admin(.*)
            form_login:
                provider: fos_userbundle
                login_path: /admin/login
                use_forward: false
                check_path: /admin/login_check
                failure_path: null
                use_referer: true #redirige al usuario a la pagina que venia antes de hacer login
            logout:
                path: /admin/logout
                target: / 

            anonymous: true
        main:
            pattern: ^/*
            form_login:
                provider: fos_userbundle
                csrf_provider: form.csrf_provider
            fos_facebook:
                app_url: "http://apps.facebook.com/subireventos/"
                server_url: "http://localhost/workspace/sdfs2.0/web/app_dev.php/"
                login_path: /login
                check_path: /login_check_fb
                provider: my_fos_facebook_provider
            logout:
            anonymous:    true

And my config.yml

fos_user:
    db_driver: orm
    firewall_name: main
    user_class: chatea\UsuarioBundle\Entity\User
    registration:
       form:
         type: sdfs_user_registration
    group: 
       group_class: sdfs\sdfsBundle\Entity\Group
    profile:
        form:
            type:               fos_user_profile
            name:               fos_user_profile_form
            validation_groups:  [Authentication]
fos_facebook:

    alias: facebook
    app_id: id
    secret: secret
    cookie: true
    permissions: [email, user_birthday, user_location]
services:
    my.facebook.user:
        class: sdfs\sdfsBundle\Security\User\Provider\FacebookProvider
        arguments:
            facebook: "@fos_facebook.api"
            userManager: "@fos_user.user_manager"
            validator: "@validator"
            container: "@service_container"

Can you help me ?

@Chrysweel commented on GitHub (Jan 28, 2013): @diegoholiveira Thanks for to reply. Still could not solve the problem. This my security.yml ``` providers: chain_provider: chain: providers: [fos_userbundle, my_fos_facebook_provider] fos_userbundle: id: fos_user.user_provider.username_email my_fos_facebook_provider: id: my.facebook.user firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false admin: switch_user: true context: user pattern: /admin(.*) form_login: provider: fos_userbundle login_path: /admin/login use_forward: false check_path: /admin/login_check failure_path: null use_referer: true #redirige al usuario a la pagina que venia antes de hacer login logout: path: /admin/logout target: / anonymous: true main: pattern: ^/* form_login: provider: fos_userbundle csrf_provider: form.csrf_provider fos_facebook: app_url: "http://apps.facebook.com/subireventos/" server_url: "http://localhost/workspace/sdfs2.0/web/app_dev.php/" login_path: /login check_path: /login_check_fb provider: my_fos_facebook_provider logout: anonymous: true ``` And my config.yml ``` fos_user: db_driver: orm firewall_name: main user_class: chatea\UsuarioBundle\Entity\User registration: form: type: sdfs_user_registration group: group_class: sdfs\sdfsBundle\Entity\Group profile: form: type: fos_user_profile name: fos_user_profile_form validation_groups: [Authentication] fos_facebook: alias: facebook app_id: id secret: secret cookie: true permissions: [email, user_birthday, user_location] services: my.facebook.user: class: sdfs\sdfsBundle\Security\User\Provider\FacebookProvider arguments: facebook: "@fos_facebook.api" userManager: "@fos_user.user_manager" validator: "@validator" container: "@service_container" ``` Can you help me ?
Author
Owner

@diegoholiveira commented on GitHub (Jan 28, 2013):

Did you follow this instruction?
https://github.com/FriendsOfSymfony/FOSFacebookBundle/blob/master/Resources/doc/1-basic-usage.md#include-the-login-button-in-your-templates

If you follow it, then post on gist.github.com your javascript that defines
the integration between JS and SF2, and then post the link here.

On Mon, Jan 28, 2013 at 5:39 PM, Chrysweel notifications@github.com wrote:

@diegoholiveira https://github.com/diegoholiveira
Thanks for to reply.
Still could not solve the problem.

This my security.yml

providers:
chain_provider:
chain:
providers: [fos_userbundle, my_fos_facebook_provider]
fos_userbundle:
id: fos_user.user_provider.username_email
my_fos_facebook_provider:
id: my.facebook.user
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false

    admin:
        switch_user: true
        context: user
        pattern: /admin(.*)
        form_login:
            provider: fos_userbundle
            login_path: /admin/login
            use_forward: false
            check_path: /admin/login_check
            failure_path: null
            use_referer: true #redirige al usuario a la pagina que venia antes de hacer login
        logout:
            path: /admin/logout
            target: /

        anonymous: true
    main:
        pattern: ^/*
        form_login:
            provider: fos_userbundle
            csrf_provider: form.csrf_provider
        fos_facebook:
            app_url: "http://apps.facebook.com/subireventos/"
            server_url: "http://localhost/workspace/sdfs2.0/web/app_dev.php/"
            login_path: /login
            check_path: /login_check_fb
            provider: my_fos_facebook_provider
        logout:
        anonymous:    true

And my config.yml

fos_user:
db_driver: orm
firewall_name: main
user_class: chatea\UsuarioBundle\Entity\User
registration:
form:
type: sdfs_user_registration
group:
group_class: sdfs\sdfsBundle\Entity\Group
profile:
form:
type: fos_user_profile
name: fos_user_profile_form
validation_groups: [Authentication]
fos_facebook:

alias: facebook
app_id: id
secret: secret
cookie: true
permissions: [email, user_birthday, user_location]

services:
my.facebook.user:
class: sdfs\sdfsBundle\Security\User\Provider\FacebookProvider
arguments:
facebook: "@fos_facebook.api"
userManager: "@fos_user.user_manager"
validator: "@validator"
container: "@service_container"

Can you help me ?


Reply to this email directly or view it on GitHubhttps://github.com/FriendsOfSymfony/FOSFacebookBundle/issues/204#issuecomment-12800000.

@diegoholiveira commented on GitHub (Jan 28, 2013): Did you follow this instruction? https://github.com/FriendsOfSymfony/FOSFacebookBundle/blob/master/Resources/doc/1-basic-usage.md#include-the-login-button-in-your-templates If you follow it, then post on gist.github.com your javascript that defines the integration between JS and SF2, and then post the link here. On Mon, Jan 28, 2013 at 5:39 PM, Chrysweel notifications@github.com wrote: > @diegoholiveira https://github.com/diegoholiveira > Thanks for to reply. > Still could not solve the problem. > > This my security.yml > > providers: > chain_provider: > chain: > providers: [fos_userbundle, my_fos_facebook_provider] > fos_userbundle: > id: fos_user.user_provider.username_email > my_fos_facebook_provider: > id: my.facebook.user > firewalls: > dev: > pattern: ^/(_(profiler|wdt)|css|images|js)/ > security: false > > ``` > admin: > switch_user: true > context: user > pattern: /admin(.*) > form_login: > provider: fos_userbundle > login_path: /admin/login > use_forward: false > check_path: /admin/login_check > failure_path: null > use_referer: true #redirige al usuario a la pagina que venia antes de hacer login > logout: > path: /admin/logout > target: / > > anonymous: true > main: > pattern: ^/* > form_login: > provider: fos_userbundle > csrf_provider: form.csrf_provider > fos_facebook: > app_url: "http://apps.facebook.com/subireventos/" > server_url: "http://localhost/workspace/sdfs2.0/web/app_dev.php/" > login_path: /login > check_path: /login_check_fb > provider: my_fos_facebook_provider > logout: > anonymous: true > ``` > > And my config.yml > > fos_user: > db_driver: orm > firewall_name: main > user_class: chatea\UsuarioBundle\Entity\User > registration: > form: > type: sdfs_user_registration > group: > group_class: sdfs\sdfsBundle\Entity\Group > profile: > form: > type: fos_user_profile > name: fos_user_profile_form > validation_groups: [Authentication] > fos_facebook: > > ``` > alias: facebook > app_id: id > secret: secret > cookie: true > permissions: [email, user_birthday, user_location] > ``` > > services: > my.facebook.user: > class: sdfs\sdfsBundle\Security\User\Provider\FacebookProvider > arguments: > facebook: "@fos_facebook.api" > userManager: "@fos_user.user_manager" > validator: "@validator" > container: "@service_container" > > Can you help me ? > > — > Reply to this email directly or view it on GitHubhttps://github.com/FriendsOfSymfony/FOSFacebookBundle/issues/204#issuecomment-12800000.
Author
Owner

@Chrysweel commented on GitHub (Jan 28, 2013):

Yes @diegoholiveira I followed it.

I have two url for check:
/login_check the route for default of FOSUserBundle
and /login_check_fb the route for FOSFacebookBundle.

Because If I use the same url for check, so I am in facebook or in my web doesnt it?
But I want be able to keep in both web

In my template I have :

<script>
  function goLogIn(){
      window.location.href = "/login_check_fb";
  }

  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 = "/logout";
              }
          });
      }
  }
</script>

My routing.yml

#FosFacebookBundle
_security_check:
      pattern:  /login_check_fb
_security_logout:
      pattern:  /logout

Any idea?

@Chrysweel commented on GitHub (Jan 28, 2013): Yes @diegoholiveira I followed it. I have two url for check: /login_check the route for default of FOSUserBundle and /login_check_fb the route for FOSFacebookBundle. Because If I use the same url for check, so I am in facebook or in my web doesnt it? But I want be able to keep in both web In my template I have : ``` <script> function goLogIn(){ window.location.href = "/login_check_fb"; } 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 = "/logout"; } }); } } </script> ``` My routing.yml ``` #FosFacebookBundle _security_check: pattern: /login_check_fb _security_logout: pattern: /logout ``` Any idea?
Author
Owner

@diegoholiveira commented on GitHub (Jan 28, 2013):

Did you check the log file?

Diego Henrique Oliveira
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Monday, 28 de January de 2013 at 19:21, Chrysweel wrote:

Yes @diegoholiveira (https://github.com/diegoholiveira) I followed it.
I have two url for check:
/login_check the route for default of FOSUserBundle
and /login_check_fb the route for FOSFacebookBundle.
In my template I have :

<script> function goLogIn(){ window.location.href = "/login_check_fb"; } 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 = "/logout"; } }); } } </script>

My routing.yml
#FosFacebookBundle _security_check: pattern: /login_check_fb _security_logout: pattern: /logout
Any idea?


Reply to this email directly or view it on GitHub (https://github.com/FriendsOfSymfony/FOSFacebookBundle/issues/204#issuecomment-12805487).

@diegoholiveira commented on GitHub (Jan 28, 2013): Did you check the log file? ## Diego Henrique Oliveira Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Monday, 28 de January de 2013 at 19:21, Chrysweel wrote: > Yes @diegoholiveira (https://github.com/diegoholiveira) I followed it. > I have two url for check: > /login_check the route for default of FOSUserBundle > and /login_check_fb the route for FOSFacebookBundle. > In my template I have : > > <script> function goLogIn(){ window.location.href = "/login_check_fb"; } 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 = "/logout"; } }); } } </script> > > My routing.yml > #FosFacebookBundle _security_check: pattern: /login_check_fb _security_logout: pattern: /logout > Any idea? > > — > Reply to this email directly or view it on GitHub (https://github.com/FriendsOfSymfony/FOSFacebookBundle/issues/204#issuecomment-12805487).
Author
Owner

@Chrysweel commented on GitHub (Jan 29, 2013):

@diegoholiveira sorry for slow to respond

Yes I checked the log file and it seems all correctly.

I included console.log() in the javascript code:

<script>
  function goLogIn(){
      window.location.href = "/login_check_fb";
  }

  function onFbInit() {
      if (typeof(FB) != 'undefined' && FB != null ) {
          FB.Event.subscribe('auth.statusChange', function(response) {
               console.log('init event');
              if (response.session || response.authResponse) {

                  setTimeout(goLogIn, 500);
              } else {
                  window.location.href = "/logout";
              }
          });
      }
  }
</script>

And I doesnt see the text in the log, I am logged to facebook...
Any idea?

@Chrysweel commented on GitHub (Jan 29, 2013): @diegoholiveira sorry for slow to respond Yes I checked the log file and it seems all correctly. I included console.log() in the javascript code: ``` <script> function goLogIn(){ window.location.href = "/login_check_fb"; } function onFbInit() { if (typeof(FB) != 'undefined' && FB != null ) { FB.Event.subscribe('auth.statusChange', function(response) { console.log('init event'); if (response.session || response.authResponse) { setTimeout(goLogIn, 500); } else { window.location.href = "/logout"; } }); } } </script> ``` And I doesnt see the text in the log, I am logged to facebook... Any idea?
Author
Owner

@Chrysweel commented on GitHub (Jan 30, 2013):

I don't find the error.

Can @diegoholiveira show me the configuration correctly for this issue please?

@Chrysweel commented on GitHub (Jan 30, 2013): I don't find the error. Can @diegoholiveira show me the configuration correctly for this issue please?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: FriendsOfSymfony/FOSFacebookBundle#116