Guest User

Untitled

a guest
Aug 5th, 2012
149
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Omniauth-facebook does not always logout user
  2. <div id="fb-root"></div>
  3. <script>
  4.  
  5. window.fbAsyncInit = function() {
  6. FB.init({
  7. appId : '(**myappid**)', // App ID
  8. status : true, // check login status
  9. cookie : true // enable cookies to allow the server to access the session
  10. });
  11.  
  12. $('#sign_in').click(function(e) {
  13. e.preventDefault();
  14. return FB.login(function(response) {
  15. if (response.authResponse) {
  16. return window.location = '/auth/facebook/callback';
  17. }
  18. });
  19. });
  20.  
  21. return $('#sign_out').click(function(e) {
  22. FB.getLoginStatus(function(response) {
  23. if (response.authResponse) {
  24. return FB.logout();
  25. }
  26. });
  27. return true;
  28. });
  29. };
  30. </script>
  31.  
  32. class SessionsController < ApplicationController
  33.  
  34. def create
  35. user = User.from_omniauth(env["omniauth.auth"])
  36. session[:user_id] = user.id
  37. redirect_to root_url
  38. end
  39.  
  40. def destroy
  41. session[:user_id] = nil
  42. redirect_to root_url
  43. end
  44. end
RAW Paste Data