Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Omniauth-facebook does not always logout user
- <div id="fb-root"></div>
- <script>
- window.fbAsyncInit = function() {
- FB.init({
- appId : '(**myappid**)', // App ID
- status : true, // check login status
- cookie : true // enable cookies to allow the server to access the session
- });
- $('#sign_in').click(function(e) {
- e.preventDefault();
- return FB.login(function(response) {
- if (response.authResponse) {
- return window.location = '/auth/facebook/callback';
- }
- });
- });
- return $('#sign_out').click(function(e) {
- FB.getLoginStatus(function(response) {
- if (response.authResponse) {
- return FB.logout();
- }
- });
- return true;
- });
- };
- </script>
- class SessionsController < ApplicationController
- def create
- user = User.from_omniauth(env["omniauth.auth"])
- session[:user_id] = user.id
- redirect_to root_url
- end
- def destroy
- session[:user_id] = nil
- redirect_to root_url
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement