__init__.py 801 B

1234567891011121314151617181920212223
  1. __version__ = '4.0.0'
  2. from social_core.backends.base import BaseAuth
  3. # django.contrib.auth.load_backend() will import and instanciate the
  4. # authentication backend ignoring the possibility that it might
  5. # require more arguments. Here we set a monkey patch to
  6. # BaseAuth.__init__ to ignore the mandatory strategy argument and load
  7. # it.
  8. def baseauth_init_workaround(original_init):
  9. def fake_init(self, strategy=None, *args, **kwargs):
  10. from .utils import load_strategy
  11. original_init(self, strategy or load_strategy(), *args, **kwargs)
  12. return fake_init
  13. if not getattr(BaseAuth, '__init_patched', False):
  14. BaseAuth.__init__ = baseauth_init_workaround(BaseAuth.__init__)
  15. BaseAuth.__init_patched = True
  16. default_app_config = 'social_django.config.PythonSocialAuthConfig'