From: Stas Kravets Date: Wed, 12 Jan 2011 16:07:52 +0000 (+0300) Subject: Merging with 0.1.3 version of base library. X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=00f3b3d17d0d06fc3ba3d9ece522458ba14224b2;p=django-social-auth.git Merging with 0.1.3 version of base library. --- 00f3b3d17d0d06fc3ba3d9ece522458ba14224b2 diff --cc example/app/views.py index 73c9618,74d2cff..edc1062 --- a/example/app/views.py +++ b/example/app/views.py @@@ -5,49 -6,11 +6,18 @@@ from django.shortcuts import render_to_ def home(request): - return HttpResponse(Template( - """ - - - Social access - - -

Login using any of the following methods:

-
-
-

Login using OAuth from:

- -
-
-

Login using OpenId from:

-
    -
  • Google
  • -
  • Yahoo
  • -
  • + """Home view, displays login mechanism""" + if request.user.is_authenticated(): + return HttpResponseRedirect('done') + else: + return render_to_response('home.html', None, RequestContext(request)) +
    {% csrf_token %} + + + +
    +
  • +
  • -
    {% csrf_token %} - - - -
    -
  • -
-
-
- - - """).render(Context(RequestContext(request))), - content_type='text/html;charset=UTF-8') @login_required def done(request): diff --cc social_auth/auth.py index bceee3e,b756e1b..bd055cc --- a/social_auth/auth.py +++ b/social_auth/auth.py @@@ -15,10 -15,9 +15,10 @@@ from django.contrib.auth import authent from .store import DjangoOpenIDStore from .backends import TwitterBackend, OrkutBackend, FacebookBackend, \ - OpenIDBackend + OpenIDBackend, GoogleBackend, YahooBackend from .conf import AX_ATTRS, SREG_ATTR, OPENID_ID_FIELD, SESSION_NAME, \ OPENID_GOOGLE_URL, OPENID_YAHOO_URL, TWITTER_SERVER, \ + OPENID_LJ_URL, OPENID_LJ_USER_FIELD, \ TWITTER_REQUEST_TOKEN_URL, TWITTER_ACCESS_TOKEN_URL, \ TWITTER_AUTHORIZATION_URL, TWITTER_CHECK_AUTH, \ FACEBOOK_CHECK_AUTH, FACEBOOK_AUTHORIZATION_URL, \ diff --cc social_auth/backends.py index a8d8936,fc5fd30..3c8eade --- a/social_auth/backends.py +++ b/social_auth/backends.py @@@ -125,31 -104,26 +104,35 @@@ class SocialAuthBackend(ModelBackend) """Return default blank user extra data""" return '' - def update_user_details(self, user, response, details): - """Update user details with new (maybe) data""" + def update_user_details(self, user, response, details, new_user=False): + """Update user details with (maybe) new data. Username is not + changed if associating a new credential.""" changed = False - for name, value in details.iteritems(): + + if not getattr(settings, 'SOCIAL_AUTH_CHANGE_SIGNAL_ONLY', False): + for name, value in details.iteritems(): + # not update username if user already exists + if not new_user and name == USERNAME: + continue - if value and value != getattr(user, name, value): - setattr(user, name, value) - changed = True - + if value and value != getattr(user, name, value): + setattr(user, name, value) + changed = True + # Fire a pre-update signal sending current backend instance, # user instance (created or retrieved from database), service # response and processed details, signal handlers must return # True or False to signal that something has changed - updated = filter(bool, pre_update.send(sender=self, user=user, + updated = filter(None, pre_update.send(sender=self, user=user, response=response, details=details)) - if changed or len(updated) > 0: + # Looking for at least one update + has_update = False + for result in updated: + if result[1]: + has_update = True + break + + if changed or has_update: user.save() def get_user_id(self, details, response): diff --cc social_auth/conf.py index 92cb895,b3b145c..a2cec51 --- a/social_auth/conf.py +++ b/social_auth/conf.py @@@ -36,11 -39,9 +39,11 @@@ AX_SCHEMA_ATTRS = ('http://axschema.org/namePerson/last', 'last_name'), ('http://axschema.org/namePerson/friendly', 'nickname'), ] - AX_ATTRS = AX_SCHEMA_ATTRS + OLD_AX_ATTRS - SREG_ATTR = ['email', 'fullname', 'nickname'] - OPENID_ID_FIELD = 'openid_identifier' - SESSION_NAME = 'openid' + AX_ATTRS = AX_SCHEMA_ATTRS + OLD_AX_ATTRS + SREG_ATTR = ['email', 'fullname', 'nickname'] + OPENID_ID_FIELD = 'openid_identifier' + SESSION_NAME = 'openid' -OPENID_GOOGLE_URL = 'https://www.google.com/accounts/o8/id' +OPENID_GOOGLE_URL = 'https://www.google.com/accounts/o8/id' - OPENID_YAHOO_URL = 'http://yahoo.com' + OPENID_YAHOO_URL = 'http://yahoo.com' +OPENID_LJ_URL = 'http://%s.livejournal.com' +OPENID_LJ_USER_FIELD = 'openid_lj_user'