Decide where to go after connecting with django-allauth

After connecting the account in the social application using django-allauth, the user is redirected to accounts/social/connections . How can I change this behavior?

+4
source share
1 answer

If the user adds more social accounts to his existing (local) account, then the most logical default would be to redirect to the connection management screen of social accounts.

However, you can easily override the default value by going through the following parameter. Look at here:

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

You will see that the next parameter is checked, returns to the default (connection).

So, to change the default behavior, just pass the following parameter:

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

If you use default templates, you will need to add the following URLs:

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

+11
source

Source: https://habr.com/ru/post/1210327/


All Articles