打开新窗口进行社交登录,然后关闭并使用Django返回父母成功 [英] Open New Window for Social Login and then Close and Return to Parent On Success with Django

查看:212
本文介绍了打开新窗口进行社交登录,然后关闭并使用Django返回父母成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Django 1.6.2和Python-Social-Auth 0.1.23。
我也使用Twitter Bootstrap作为我的模板引擎。



我将python-social-auth用于我的模板,并实现了一个LinkedIn登录对于我的客户,我已编码它,以便登录在新窗口中使用javascript打开。

 < li> 
< a class =btnhref =
onclick =window.open('{%url'social:begin''linkedin'%}','_blank','location =是,高度= 570,宽度= 520,滚动条=是,状态=是);>
< span class =glyphicon glyphicon-user>< / span>登录< / a>< / li>

我的问题是,如何关闭这个子窗口并成功重新加载父窗口登录?



我意识到这个问题可能是非常具体的,但有人不得不实现同样的想法。只是一点点:如果可以,我不想编辑任何python-social-auth的东西。



让我知道如果有其他的你可以使用的信息。我也可以包含我的views.py。

解决方案

你已经解决了一个弹出窗口部分,关闭是棘手的一个,因为你需要提供一些页面与所需的JS代码来关闭弹出窗口,然后在父窗口中触发重新加载。为了做到这一点,只需定义 SOCIAL_AUTH_LOGIN_REDIRECT_URL ='/ page / that / servers / the / js'的设置,然后创建一个视图/模板。 >

查看父代的关闭和触发重载是否完成,这很简单,并将JS提供给用户。


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.

这篇关于打开新窗口进行社交登录,然后关闭并使用Django返回父母成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆