Open New Window for Social Login and then Close and Return to Parent On Success with Django

偶尔善良 提交于 2019-12-05 06:19:35

You solved the opening-in-a-popup part already, the closing is the tricky one, for that you need to serve some page with the needed JS code to close the popup and then trigger the reload in the parent window. To make that possible, just define the setting SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/page/that/servers/the/js' and then create the view/template that does that.

Check around how closing and triggering reload in the parent is done, it's quite easy, and serve that JS to the user.

I had the same issue. My solution was to set the successful redirect login in my settings.py file. SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/close/'

Then map that in my urls file url(r'^close/$', TemplateView.as_view(template_name='close.html')),

Then have my close.html contain a single script tag to close the browser window on load without triggering a confirmation popup.

<script>
    window.open('', '_self', ''); window.close();
</script>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!