decide where to go to after connecting with django-allauth

巧了我就是萌 提交于 2019-11-27 18:51:59

问题


After connecting an account with a social app using django-allauth the user is redirected to accounts/social/connections. How can I change this behavior?


回答1:


If the user is adding more social accounts to his existing (local) account, then the most logical default would be indeed to redirect to the social account connections management screen.

However, you can easily override the default by passing along a next parameter. Have a look here:

https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/helpers.py#L125

You'll see that the next parameter is checked, falling back to the default (connections).

So, to change the default behavior, simply pass along a next parameter:

<a href="{% provider_login_url "openid" openid="https://www.google.com/accounts/o8/id" next="/success/url/" %}">Google</a>

If you are using the default templates you'll have to add next urls here:

https://github.com/pennersr/django-allauth/blob/master/allauth/templates/socialaccount/connections.html#L53



来源:https://stackoverflow.com/questions/13295603/decide-where-to-go-to-after-connecting-with-django-allauth

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