답변

3

할 수있는 것처럼 보입니다. 이 너 자신?

사용자가 'facebook을 통해 로그인'을 클릭하면 JS를 사용하여/auth/facebook의 위치가있는 창을 엽니 다. 'callback'은이 같은 창에서/auth/callback으로 되돌아갑니다. 콜백 작업을 완료하면 현재 창을 닫고 부모를 새로 고칩니다.

+0

감사합니다. cory!/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'로 바꾸면 작동합니다. 콜백 URL에서

,

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

당신이 @redirect_to이 당신의 부모 창에 갱신되어야하는 페이지를 가리키는 싶어하지만 당신은 페이지를 새로 고칠 수 있습니다.

+0

그것은 거의 정확히 내가 어떻게 그랬는지. 감사! D = 제가 렌더링 컨트롤러에서 JS 호출 트리거 –

+0

altho : 텍스트 = "" ": –

+0

'HTML은'타입 =>는 빠르다 render : layout => false – siong1987

관련 문제