]> git.openstreetmap.org Git - osqa.git/blobdiff - forum_modules/openidauth/consumer.py
resolves a typo in user suspend functionality, indefinetly should be indefinitely...
[osqa.git] / forum_modules / openidauth / consumer.py
index 9b5d6e712ec06b055d3d0ecf20afb362027f9324..aa24a36c69ba77bf341f9c1c635fd82106baf818 100644 (file)
@@ -1,5 +1,8 @@
+# -*- coding: utf-8 -*-
+
 import re
 
+from django.utils.encoding import smart_unicode
 from django.utils.html import escape
 from django.http import get_host
 
@@ -41,7 +44,7 @@ class OpenIdAbstractAuthConsumer(AuthenticationConsumer):
 
     def prepare_authentication_request(self, request, redirect_to):
         if not redirect_to.startswith('http://') or redirect_to.startswith('https://'):
-                   redirect_to =  get_url_host(request) + redirect_to
+            redirect_to =  get_url_host(request) + redirect_to
 
         user_url = self.get_user_url(request)
 
@@ -78,9 +81,9 @@ class OpenIdAbstractAuthConsumer(AuthenticationConsumer):
             axr = AXFetchRequest()
             for data_type, schema in ax_schema.items():
                 if isinstance(schema, tuple):
-                    axr.add(AttrInfo(schema[0], 1, True, schema[1]))
+                    axr.add(AttrInfo(schema[0], required=True, alias=schema[1]))
                 else:
-                    axr.add(AttrInfo(schema, 1, True, data_type))
+                    axr.add(AttrInfo(schema, required=True, alias=data_type))
 
             auth_request.addExtension(axr)
 
@@ -94,7 +97,7 @@ class OpenIdAbstractAuthConsumer(AuthenticationConsumer):
         consumer = Consumer(request.session, OsqaOpenIDStore())
 
         query_dict = dict([
-            (k.encode('utf8'), v.encode('utf8')) for k, v in request.GET.items()
+            (smart_unicode(k), smart_unicode(v)) for k, v in request.GET.items()
         ])
 
         #for i in query_dict.items():
@@ -123,7 +126,7 @@ class OpenIdAbstractAuthConsumer(AuthenticationConsumer):
             ax_schema = getattr(self, 'dataype2ax_schema', False)
 
             if ax_schema:
-                ax = AXFetchResponse.fromSuccessResponse(openid_response)
+                ax = AXFetchResponse.fromSuccessResponse(openid_response, False)
 
                 if ax:
                     axargs = ax.getExtensionArgs()
@@ -137,7 +140,8 @@ class OpenIdAbstractAuthConsumer(AuthenticationConsumer):
 
                     for t, s in available_types.items():
                         if not t in consumer_data:
-                            consumer_data[t] = axargs["value.%s.1" % s]
+                            if axargs.get("value.%s.1" % s, None):
+                                consumer_data[t] = axargs["value.%s.1" % s]
                     
             request.session['auth_consumer_data'] = consumer_data