]> git.parisson.com Git - django-social-auth.git/commitdiff
Get rid of session logging (?) and replaced by proper Python error logging, including...
authorMathijs de Bruin <mathijs@mathijsfietst.nl>
Mon, 19 Sep 2011 12:52:35 +0000 (14:52 +0200)
committerMathijs de Bruin <mathijs@mathijsfietst.nl>
Mon, 19 Sep 2011 12:53:06 +0000 (14:53 +0200)
social_auth/views.py

index a48aba6e711222d426c219d44440f1e9835ad2fd..79a55f32bf46f7731231c60ba917578ed95470b7 100644 (file)
@@ -68,16 +68,29 @@ def dsa_view(redirect_name=None):
                 return func(request, backend, *args, **kwargs)
             except Exception, e:  # some error ocurred
                 backend_name = backend.AUTH_BACKEND.name
+
+                logger.error(unicode(e), exc_info=True,
+                             extra=dict(request=request))
+
+                # Why!?
                 msg = str(e)
 
                 if 'django.contrib.messages' in settings.INSTALLED_APPS:
                     from django.contrib.messages.api import error
                     error(request, msg, extra_tags=backend_name)
                 else:
-                    if ERROR_KEY:  # store error in session
-                        request.session[ERROR_KEY] = msg
-                    if NAME_KEY:  # store the backend name for convenience
-                        request.session[NAME_KEY] = backend_name
+                    logger.warn('Messages framework not in place, some '+
+                                'errors have not been shown to the user.')
+                # What's the use in this, having not both the messages
+                # framework and decent logging in place?
+                # Also: do we really want to share all and any errors back
+                # to the user, in a security-wise sensitive application?
+                #
+                # else:
+                #     if ERROR_KEY:  # store error in session
+                #         request.session[ERROR_KEY] = msg
+                #     if NAME_KEY:  # store the backend name for convenience
+                #         request.session[NAME_KEY] = backend_name
                 return HttpResponseRedirect(BACKEND_ERROR_REDIRECT)
         return wrapper
     return dec