如果您在现有窗口中打开omniauth的默认值,则可以很好地工作,但不确定它在弹出式上下文中的工作原理,并且您正在通过JavaScript处理大部分交互作用

有帮助吗?

解决方案

好像你可以自己做吗?

当用户单击“通过Facebook登录”时 - 使用JS弹出使用 /auth /facebook位置的窗口。 “回调”只会在同一窗口中返回到 /auth /callback。完成回调后,关闭当前窗口并刷新父母?

其他提示

var newwindow;
function login(provider_url, width, height) {
  var screenX     = typeof window.screenX != 'undefined' ? window.screenX : window.screenLeft,
      screenY     = typeof window.screenY != 'undefined' ? window.screenY : window.screenTop,
      outerWidth  = typeof window.outerWidth != 'undefined' ? window.outerWidth : document.body.clientWidth,
      outerHeight = typeof window.outerHeight != 'undefined' ? window.outerHeight : (document.body.clientHeight - 22),
      left        = parseInt(screenX + ((outerWidth - width) / 2), 10),
      top         = parseInt(screenY + ((outerHeight - height) / 2.5), 10),
      features    = ('width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);

      newwindow = window.open(provider_url, 'Login', features);

  if (window.focus)
    newwindow.focus();

  return false;
}

用“/auth/facebook”或“/auth/twitter”替换提供者_url。

在您的回调URL,

<script type="text/javascript">
  window.opener.location = '<%= @redirect_to %>';
  window.close();
</script>

您可以使用@redirect_to指向您的父窗口应刷新的页面。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top