]> git.parisson.com Git - django-social-auth.git/commitdiff
Patch for login error message.
authorSandeep <sandeep@systematixtechnocrates.com>
Sat, 3 Dec 2011 10:43:45 +0000 (16:13 +0530)
committerSandeep <sandeep@systematixtechnocrates.com>
Tue, 6 Dec 2011 11:16:09 +0000 (16:46 +0530)
social_auth/views.py

index 139cfcaf3185becfce48e076b6d2490af3795e78..e0d0e7314d923d674f3266ad474e5e7e3e0f15f7 100644 (file)
@@ -16,6 +16,7 @@ from django.http import HttpResponseRedirect, HttpResponse, \
 from django.core.urlresolvers import reverse
 from django.contrib.auth import login, REDIRECT_FIELD_NAME
 from django.contrib.auth.decorators import login_required
+from django.contrib import messages
 from django.views.decorators.csrf import csrf_exempt
 
 from social_auth.backends import get_backend
@@ -37,6 +38,7 @@ SESSION_EXPIRATION = setting('SOCIAL_AUTH_SESSION_EXPIRATION', True)
 BACKEND_ERROR_REDIRECT = setting('SOCIAL_AUTH_BACKEND_ERROR_URL',
                                  LOGIN_ERROR_URL)
 SANITIZE_REDIRECTS = setting('SOCIAL_AUTH_SANITIZE_REDIRECTS', True)
+ERROR_MESSAGE = setting('LOGIN_ERROR_MESSAGE', None)
 
 
 def dsa_view(redirect_name=None):
@@ -170,6 +172,8 @@ def complete_process(request, backend, *args, **kwargs):
               request.session.pop(REDIRECT_FIELD_NAME, '') or \
               DEFAULT_REDIRECT
     else:
+        if ERROR_MESSAGE:
+            messages.error(request, ERROR_MESSAGE)
         url = LOGIN_ERROR_URL
     return HttpResponseRedirect(url)