使用 devise 时如何清除 facebook 会话和 cookie +全方位认证 +轨道3?
我使用 devise +omniauth on Rails 3 实现了使用 facebook connect 的帐户创建和登录。但是,我的问题是在用户注销时清除 facebook 会话和 cookie。目前,当用户注销时,似乎会清除当前会话。但是,当用户再次登录时,由于 facebook cookie,它会自动让用户登录。我希望使用sign_out方法来清除cookie,以便当用户下次尝试登录时,它会要求用户使用facebook登录。
现在我正在使用默认的设计路线“devise_for:users”。我应该通过创建“class SessionsController < Devise::SessionsController”来覆盖它吗?如果是这样,我需要编写 create 和 destroy 方法吗?在 destroy 方法中,如何准确清除 fb cookie?
任何帮助将不胜感激!
I implemented account creation and login using facebook connect using devise + omniauth on rails 3. My problem, however, is clearing facebook session and cookies when user logs out. Currently when a user signs out, it seems to clear current session. However, when a user signs in again, it automatically logs the user in because of the facebook cookie. I'd like the sign_out method to clear the cookie so that when a user tries to log in next time, it will ask user to sign in with facebook.
Right now I am using the default devise route "devise_for :users". Shall I overwrite it by creating "class SessionsController < Devise::SessionsController"? If so, do I need to write both create and destroy methods? In destroy method, how do I exactly clear fb cookie(s)?
Any help would be much appreciated!
为了清除 FB 会话,您必须使用 FB JS SDK。
所以,这就是我所做的。
首先,初始化FB JS。我使用了部分,但你可以将其放在布局中
然后,我将注销链接绑定到调用 application.js 中的 destroy_user_session_path 的 FB.logout 函数。
我的application.html.erb。
In order to clear out FB session, you have to use FB JS SDK.
So, here is what I did.
First, init FB JS. I used a partial, but you can just put this this in layout
Then, I bound logout link to a FB.logout function that calls destroy_user_session_path in application.js.
My application.html.erb.