From: Hannes Struss Date: Thu, 7 Jun 2012 16:43:58 +0000 (+0200) Subject: introduced setting SOCIAL_AUTH_PROTECTED_USER_FIELDS X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=c3ce70a970e279b00b08423d28eb393aa6a977b1;p=django-social-auth.git introduced setting SOCIAL_AUTH_PROTECTED_USER_FIELDS this can be a tuple of field-names on the user object, which django-social-auth will not overwrite when the user already existed, i.e. was not created in the current auth process. --- diff --git a/social_auth/backends/pipeline/user.py b/social_auth/backends/pipeline/user.py index 9ebaf03..6cd3676 100644 --- a/social_auth/backends/pipeline/user.py +++ b/social_auth/backends/pipeline/user.py @@ -91,7 +91,9 @@ def update_user_details(backend, details, response, user, is_new=False, *args, if not setting('SOCIAL_AUTH_CHANGE_SIGNAL_ONLY'): for name, value in details.iteritems(): # do not update username, it was already generated - if name in (USERNAME, 'id', 'pk'): + # do not update configured fields if user already existed + if name in (USERNAME, 'id', 'pk') or (not is_new and + name in setting('SOCIAL_AUTH_PROTECTED_USER_FIELDS', [])): continue if value and value != getattr(user, name, None): setattr(user, name, value)