A Python Zagreb meetup talk about why we should not be afraid of poking into someone else's code.
Look behind the curtainSenko Rašić
View Slide
“When the getDVRConversions is set to Trueit expires conversions automatically.”—paid supportProprietary software
Open Source
Sign in with Google * *authorized users only
from allauth.socialaccount.adapter import \ DefaultSocialAccountAdapterclass MyAdapter(DefaultSocialAccountAdapter):def is_open_for_signup(self, request):return False
from allauth.socialaccount.adapter import \ DefaultSocialAccountAdapterclass MyAdapter(DefaultSocialAccountAdapter):def is_open_for_signup(self, req, sociallogin):return False
Django Developer TragediesAllAuth won’t log in without SocialAccount,but won’t create SocialAccount without signup.
We need to go deeper
allauth.socialaccount.views.SignupView
a.sa.providers.google.views.oauth2_logina.sa.providers.oauth2.views.OAuth2LoginView↓↓a.sa.providers.google.views.oauth2_callbacka.sa.providers.oauth2.views.OAuth2CallbackView↓allauth.socialaccount.views.SignupView
class OAuth2CallbackView(OAuth2View):def dispatch(self, request):…login = self.adapter.complete_login(…)…return complete_social_login(request, login)↓# allauth.socialaccount.helpersdef _complete_social_login(req, sociallogin):…if sociallogin.is_existing:…else:ret = _process_signup(req, sociallogin)↓# allauth.socialaccount.modelsclass SocialLogin(object):@propertydef is_existing(self):return self.account.pk
# a.sa.provider.google.viewsclass GoogleOAuth2Adapter(OAuth2Adapter):def complete_login(…):…login = self.get_provider(). \sociallogin_from_response(…)↓# a.sa.providers.baseclass Provider(object):def sociallogin_from_response(…):…sociallogin.user = adapter.new_user(req, sociallogin)…↓
# allauth.socialaccount.modelsclass SocialLogin(object):@propertydef is_existing(self):return self.account.pk
# allauth.socialaccount.helpersdef complete_social_login(request, sociallogin):assert not sociallogin.is_existing…
千⾥里里之⾏行行,始於⾜足下Debugging ofthousand linesstarts with a single step
Thank you!@senkorasic