min*_*eow 3 authentication ruby-on-rails oauth twitter-oauth omniauth
如果你在现有窗口中打开Omniauth,默认情况下效果很好,但是不确定它在弹出上下文中是如何工作的,你通过javascript处理很大一部分交互
sio*_*987 15
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;
}
Run Code Online (Sandbox Code Playgroud)
将provider_url替换为'/ auth/facebook'或'/ auth/twitter'应该有效.
在你的回调网址,
<script type="text/javascript">
window.opener.location = '<%= @redirect_to %>';
window.close();
</script>
Run Code Online (Sandbox Code Playgroud)
您可以使用@redirect_to指向要将父窗口刷新到的页面随意刷新页面.
| 归档时间: |
|
| 查看次数: |
3630 次 |
| 最近记录: |