I'm working with Django 1.6.2 and Python-Social-Auth 0.1.23. I'm also working with Twitter Bootstrap as my templating engine.

I've worked python-social-auth into my template and implemented a LinkedIn log in for my customers and I've coded it so that the login opens in a new window using javascript.

<li>
    <a class="btn" href="" 
        onclick="window.open('{% url 'social:begin' 'linkedin' %}', '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');">
<span class="glyphicon glyphicon-user"></span> Sign In</a></li>

My question is, how can I close this child window and reload the parent window upon successful login?

I realize this question might be pretty specific but someone has had to implement the same idea before. Just a little heads up: if I can, I don't want to edit any of the python-social-auth stuff.

Let me know if there is any other information you could use. I can include my views.py also.

有帮助吗?

解决方案

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>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top