pennersr / django-allauth

Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.
https://allauth.org
MIT License
9.54k stars 3.03k forks source link

Instrumentation of complete_social_login() #1676

Closed jleclanche closed 2 years ago

jleclanche commented 7 years ago

I'm trying to understand the way that complete_social_login() works.

My use case: I want to add instrumentation to the login, specifically I want to know when users are using the "connect" process.

I already do this on user creation and auth errors, which is easy because of the new_user() and authentication_error() methods on the social account adapter:

https://github.com/HearthSim/HSReplay.net/blob/master/hsreplaynet/accounts/providers.py#L33

But it appears that the connect process doesn't call into a provider method. It calls the internal function _add_social_account which seldom calls into the provider at all. Is there a chance this can call back into the provider a bit more? I can help work on that if we agree on a design.

pennersr commented 7 years ago

There is a signal emitted when a user connects a new social account, would that help?:

# Sent after a user connects a social account to a their local account.
social_account_added = Signal(providing_args=["request", "sociallogin"])
jleclanche commented 7 years ago

Yes, I think that helps. However, in a more general sense, it would still be nice to have that whole procedure be part of the provider class -- would it make sense? That way we have more access on overridable behaviour and can do more fine-grained instrumentation. Right now, gotta monkey patch if we want to do that.

karthikrajender commented 7 years ago

Hi pennersr

I had over ride the social account adapter by setting it in social account adapter

SOCIALACCOUNT_ADAPTER = 'xxx.xxx.xxx.xx' - path

i have introduced a new text field or custom field , in adapter function save_user(), how can i get the custom field to get stored in database.

pennersr commented 2 years ago

Closing -- using signals+adapter this can be done.