password=UNUSABLE_PASSWORD)
# update details and associate account with social credentials
- try:
- self.update_user_details(user, response, details)
- self.associate_auth(user, response, details)
- except Exception, e:
- print str(e)
+ self.update_user_details(user, response, details)
+ self.associate_auth(user, response, details)
return user
def associate_auth(self, user, response, details):
def get_user_details(self, response):
"""Return user details from Facebook account"""
- import pprint
- pprint.pprint(response)
return {'email': response.get('email', ''),
'username': response['name'],
'fullname': response['name'],
--- /dev/null
+"""Signals"""
+from django.dispatch import Signal
+
+# Pre save signal
+# This signal is sent when user instance values is about to be
+# updated with new values from services provided. This way custom
+# actions can be attached and values updated if needed before the
+# saving time.
+#
+# Handlers must return True if any value was updated/changed,
+# otherwise must return any non True value.
+#
+# The parameters passed are:
+# sender: A social auth backend instance
+# user: Current user instance (retrieved from db or recently
+# created)
+# response: Raw auth service response
+# details: Processed details values (basic fields)
+pre_update = Signal(providing_args=['user', 'response', 'details'])
return HttpResponseServerError('Incorrect authentication service')
backend = BACKENDS[backend](request, request.path)
user = backend.auth_complete()
- print "USER:", user
if user and user.is_active:
login(request, user)
url = request.session.pop(REDIRECT_FIELD_NAME, '') or \