Created
February 18, 2019 12:07
-
-
Save goltsevnet/a73bbe0fae332add07ba2659feb4ab6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.contrib.auth.models import User | |
| from allauth.account.models import EmailAccount | |
| from allauth.exceptions import ImmediateHttpResponse | |
| from allauth.socialaccount.adapter import DefaultSocialAccountAdapter | |
| class MyAdapter(DefaultSocialAccountAdapter): | |
| def pre_social_login(self, request, sociallogin): | |
| # This isn't tested, but should work | |
| try: | |
| user = User.objects.get(email=sociallogin.email) | |
| sociallogin.connect(request, user) | |
| # Create a response object | |
| raise ImmediateHttpResponse(response) | |
| except User.DoesNotExist: | |
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SOCIALACCOUNT_ADAPTER = 'myapp.my_adapter.MyAdapter` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment