答えて

3

はそうジャバスクリプトを経由してあなたが相互作用の大部分を処理していますこれはあなた自身ですか?

ユーザーが「facebook経由でログイン」をクリックすると、JSを使用して、/ auth/facebookの場所があるウィンドウが開きます。 'コールバック'はこの同じウィンドウで/ auth/callbackに戻るだけです。コールバックを使って作業を終えたら、現在のウィンドウを閉じて親をリフレッシュしますか?

+0

ありがとうコーリー!/auth/callbackは、さまざまなネットワークを処理する汎用関数ですか? –

+0

それは働いて、ありがとう! = D –

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; 
} 

provider_urlを '/ auth/facebook'または '/ auth/twitter'に置き換えると効果があります。あなたが欲しいしかし、あなたは@redirect_toがあなたの親ウィンドウがにリフレッシュする必要があるページを指すでページを更新することができ、あなたのコールバックURL、

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

+0

これは私が最後にやったこととほとんど同じでした。ありがとう! ";