1

I used Chris Heald's answer here: "http://stackoverflow.com/questions/4491433/turn-omniauth-facebook-login-into-a-popup" and it worked perfectly.

The one issue is in the redirect. I am using Devise and Oauth for Facebook login - I want the popup to close after login and for the user to be redirected to the proper page after sign-in/sign-up.

For some reason, right now, the proper path is loaded in the pop-up window and the pop-up window doesn't close. I think I'm missing something very basic. Any ideas? I am a total JS newb!!

JS for Popup:

function popupCenter(url, width, height, name) {
    var left = (screen.width/2)-(width/2);
    var top = (screen.height/2)-(height/2);
    return window.open(url, name, "menubar=no,toolbar=no,status=no,width="+width+",height="+height+",toolbar=no,left="+left+",top="+top);
  }

  $("a.popup").click(function(e) {
    popupCenter($(this).attr("href"), $(this).attr("data-width"), $(this).attr("data-height"), "authPopup");
    e.stopPropagation(); return false;
});

JS for Redirect:

if(window.opener) {
    window.opener.location = <%= after_sign_in_path %>;
    window.close()
  }
abhir
  • 1,059
  • 1
  • 9
  • 25

1 Answers1

0

Are you sure your after_sign_in_path is in quotes? You might want to try this instead:

window.opener.location = "<%= after_sign_in_path %>"

I'm suspecting the window isn't closing because there's a javascript error before that line is executed.

Mario
  • 615
  • 7
  • 7