offline avatar offline committed 29915b9

facebook bug fixed + new style of flash messages used

Comments (0)

Files changed (4)

publicauth/backends/facebook.py

 from __future__ import absolute_import 
 
 from django.contrib import messages
+from django.conf import settings
 
 from annoying.exceptions import Redirect
 
     
     def validate(self, request, data):
         if not request.facebook.validate_cookie_signature(request.COOKIES):
-            messages.add_message(request, messages.ERROR, lang.FACEBOOK_INVALID_RESPONSE)
+            messages.error(request, lang.FACEBOOK_INVALID_RESPONSE)
             raise Redirect('publicauth-login')
         else:
             uid = request.facebook.api_key
             return request.facebook
 
     def complete(self, request, response):
+        request.session['next_url'] = request.GET.get("next") or settings.LOGIN_REDIRECT_URL
         data = self.fill_extra_fields(request, self.get_extra_data(response))
         request.session['extra'] = data
         request.session['identity'] = self.identity

publicauth/backends/oauth.py

             oauth_token = data['oauth_token']
             oauth_verifier = data.get('oauth_verifier', None)
         except MultiValueDictKeyError:
-            messages.add_message(request, messages.ERROR, lang.BACKEND_ERROR)
+            messages.error(request, lang.BACKEND_ERROR)
             raise Redirect('publicauth-login')
         oauth_req = OAuthRequest.from_consumer_and_token(consumer, http_url=self.ACCESS_TOKEN_URL)
         oauth_req.set_parameter('oauth_token', oauth_token)

publicauth/backends/openid.py

         try:
             openid_url = data['openid_url'].strip()
         except KeyError:
-            messages.add_message(request, messages.ERROR, lang.FILL_OPENID_URL)
+            messages.error(request, lang.FILL_OPENID_URL)
+            raise Redirect('publicauth-login')
 
         # allow user to type openid provider without http:// prefix
         if not openid_url.startswith("http"):
             raise Redirect(redirect_url)
 
         except discover.DiscoveryFailure:
-            messages.add_message(request, messages.ERROR, _('Could not find OpenID server'))
+            messages.error(request, _('Could not find OpenID server'))
             raise Redirect('publicauth-login')
 
     def validate(self, request, data):
         try:
             resp = client.complete(data, request.session['openid_return_to'])
         except KeyError:
-            messages.add_message(request, messages.ERROR, lang.INVALID_RESPONSE_FROM_OPENID)
+            messages.error(request, lang.INVALID_RESPONSE_FROM_OPENID)
             raise Redirect('publicauth-login')
         if resp.status == consumer.CANCEL:
-            messages.add_message(request, messages.WARNING, lang.OPENID_CANCELED)
+            messages.worning(request, lang.OPENID_CANCELED)
             raise Redirect('publicauth-login')
         elif resp.status == consumer.FAILURE:
-            messages.add_message(request, messages.ERROR, lang.OPENID_FAILED % resp.message)
+            messages.error(request, lang.OPENID_FAILED % resp.message)
             raise Redirect('publicauth-login')
         elif resp.status == consumer.SUCCESS:
             self.identity = resp.identity_url

publicauth/views.py

 
 def logout(request):
     auth.logout(request)
-    messages.add_message(request, messages.SUCCESS, lang.SUCCESS_LOGOUT)
+    messages.success(request, lang.SUCCESS_LOGOUT)
     return redirect(global_settings.LOGOUT_URL)
 
 
     else:
         backend.login_user(request)
         if not settings.REGISTRATION_ALLOWED:
-            messages.add_message(request, messages.WARNING, lang.REGISTRATION_DISABLED)
+            messages.warning(request, lang.REGISTRATION_DISABLED)
             return redirect(settings.REGISTRATION_DISABLED_REDIRECT)
 
     return backend.complete(request, response)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.