allauth_authentic2/provider: update user first_name and last_name event after its first connection
This commit is contained in:
parent
1e4add7841
commit
a7ed8a9646
|
@ -48,3 +48,17 @@ class Authentic2Provider(OAuth2Provider):
|
|||
|
||||
|
||||
providers.registry.register(Authentic2Provider)
|
||||
|
||||
from allauth.socialaccount.signals import pre_social_login
|
||||
from django.dispatch import receiver
|
||||
|
||||
@receiver(pre_social_login)
|
||||
def pre_social_login_populate_user(sender, request, sociallogin, **kwargs):
|
||||
account = sociallogin.account
|
||||
data = account.extra_data
|
||||
user = account.user
|
||||
if 'first_name' in data:
|
||||
user.first_name = data['first_name']
|
||||
if 'last_name' in data:
|
||||
user.last_name = data['last_name']
|
||||
user.save()
|
||||
|
|
Reference in New Issue