Check FB Connect session end using facebooker

how to check if an FB Connect session is valid or not using the facebooker rails plugin? Is there an assistant or module that can check the session? I will find out that if I open 2 tabs in the browser, one login with facebook, the other with my website and login using FB Connect. When a user tries to log out on my site, facebook erases both cookies, but when a user logs out via facebook, he only removes the cookie on the facebook site, so the cookie on my site is still behind, and I need to check if the cookie is valid or not...

+3
source share
3 answers

Using Facebooker, you will get an exception when you try to use an exception that can be saved in the .rb application

rescue_from Facebooker::Session::SessionExpired, :with => :facebook_session_expired

def facebook_session_expired
  clear_fb_cookies!
  clear_facebook_session_information
  reset_session # remove your cookies!
  flash[:error] = "Your facebook session has expired."
  redirect_to root_url
end
+3
source

I cannot promote things yet, but the answer that adds the line is:

page.redirect_to url

is correct. I would recommend adding it to Facebook if Mike is reading.

+1
source

The method is fb_logout_linknot redirected when the Facebook session is invalid. Add a redirect callback to your logout_path and it will do the job for you.

    def fb_logout_link(text,url,*args)
      js = update_page do |page|
        page.call "FB.Connect.logoutAndRedirect",url
        # When session is valid, this call is meaningless, since we already redirect
        # When session is invalid, it will log the user out of the system.
        page.redirect_to url # You can use any *string* based path here
      end
      link_to_function text, js, *args
    end
0
source

Source: https://habr.com/ru/post/1718403/


All Articles