Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
377 views
in Technique[技术] by (71.8m points)

decide where to go to after connecting with django-allauth

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...