Omniauth facebook ajax

Currently, my login with facebook button works fine when browsers click /auth/facebook. However, I would prefer to be able to log in without refreshing the page. I am trying to do something like this:

$(document).ready(function() {
  var $login;
  $login = $('#login');
  return $login.click(function(event) {
    event.preventDefault();
    console.log("Trying to log in");
    return $.ajax({
      url: $login.attr('href'),
      data: {},
      complete: function(response) {
        return console.log(response);
      }
    });
  });
});

but I don't seem to get any useful data from the response, and the browser seems to cancel the redirect (according to the web developers panel in chrome). Is there a way to get this to work with omniauth?

I do not want to use iframes.

+3
source share
1 answer

Before you try to do this, you need to understand how omniauth works. Then you can choose the most suitable solution.

0
source

All Articles