Abhilash Raj has proposed merging lp:~raj-abhilash1/postorius/browserid into 
lp:postorius.

Requested reviews:
  Mailman Coders (mailman-coders)

For more details, see:
https://code.launchpad.net/~raj-abhilash1/postorius/browserid/+merge/251950

Replace django-social-auth with django-browserid for python3 compatibility.
-- 
Your team Mailman Coders is requested to review the proposed merge of 
lp:~raj-abhilash1/postorius/browserid into lp:postorius.
=== modified file 'setup.py'
--- setup.py	2015-02-10 13:56:47 +0000
+++ setup.py	2015-03-05 14:27:55 +0000
@@ -40,6 +40,6 @@
     package_dir={'': 'src'},
     include_package_data=True,
     install_requires=['django>=1.5',
-                      'django-social-auth>=0.7.8',
+                      'django-browserid',
                       'mailmanclient']
 )

=== modified file 'src/postorius/templates/postorius/login.html'
--- src/postorius/templates/postorius/login.html	2015-01-30 20:30:22 +0000
+++ src/postorius/templates/postorius/login.html	2015-03-05 14:27:55 +0000
@@ -2,8 +2,10 @@
 {% load url from future %}
 {% load i18n %}
 {% load staticfiles %}
+{% load browserid %}
 {% block main %}
 
+{% browserid_info %}
 <div id="container">
     <p><strong>{% trans "Login with username and password or with Mozilla Persona" %}</strong></p>
 
@@ -17,15 +19,18 @@
     </form>
 
   </div>
-
   <div class="mm_login_b">
-    <form method="post" action="{% url 'socialauth_complete' "browserid" %}"> {% csrf_token %}
-      <input type="hidden" name="assertion" value="" />
-      <a rel="nofollow" id="browserid" href="#"><img src="{% static 'postorius/img/sign_in_blue.png' %}" alt="{% trans 'Login using BrowserID' %}" /></a>
-    </form>
-    <p>{% trans "Mozilla Persona is an easy way to sign into multiple websites, while still controlling your personal data. For more information <a href='http://www.mozilla.org/en-US/persona'>see the Mozilla website</a>" %}.</p>
-    <noscript><p class="text-error">{% trans "Mozilla Persona requires the use of
-JavaScript." %}</p></noscript>
+    <a rel="nofollow" id="browserid" href="#">
+      <img src="{% static 'postorius/img/sign_in_blue.png' %}"
+           alt="{% trans 'Login using BrowserID' %}" />
+    </a>
+    <p>{% trans "Mozilla Persona is an easy way to sign into multiple websites, while still controlling your personal data. For more information <a href='http://www.mozilla.org/en-US/persona'>see the Mozilla website</a>" %}.
+    </p>
+    <noscript>
+      <p class="text-error">
+        {% trans "Mozilla Persona requires the use of JavaScript." %}
+      </p>
+    </noscript>
   </div>
 <div style="clear:both">
 </div>
@@ -35,24 +40,19 @@
 {% block additionaljs %}
 <!-- Include BrowserID JavaScript -->
 <script src="https://login.persona.org/include.js"; type="text/javascript"></script>
+<script src="{% static 'browserid/api.js' %}" type="text/javascript"></script>
+<script src="{% static 'browserid/browserid.js' %}" type="text/javascript"></script>
 <!-- Setup click handler that receives BrowserID assertion code and sends
      POST data -->
 <script type="text/javascript">
     $(function () {
-        $('#browserid').click(function (e) {
-            e.preventDefault();
-            var self = $(this);
-
-            navigator.id.get(function (assertion) {
-                if (assertion) {
-                    self.parent('form')
-                            .find('input[type=hidden]')
-                                .attr('value', assertion)
-                                .end()
-                            .submit();
-                } 
-            });
+      $('#browserid').click(function (e) {
+        django_browserid.login().then(function(verifyResult) {
+          window.location = verifyResult.redirect;
+        }, function(jqXHR) {
+          window.alert('There was an error logging in, please try again.');
         });
+      });
     });
 </script>
 <!-- end browserid stuff -->

=== modified file 'testing/test_settings.py'
--- testing/test_settings.py	2015-02-09 22:16:49 +0000
+++ testing/test_settings.py	2015-03-05 14:27:55 +0000
@@ -89,8 +89,7 @@
 
 AUTHENTICATION_BACKENDS = (
     'django.contrib.auth.backends.ModelBackend',
-    'social_auth.backends.OpenIDBackend',
-    'social_auth.backends.browserid.BrowserIDBackend',
+    'django_browserid.auth.BrowserIDBackend',
 )
 
 TEMPLATE_CONTEXT_PROCESSORS = (
@@ -103,9 +102,6 @@
     "django.core.context_processors.csrf",
     "django.contrib.messages.context_processors.messages",
     "postorius.context_processors.postorius",
-    'social_auth.context_processors.social_auth_by_name_backends',
-    'social_auth.context_processors.social_auth_backends',
-    'social_auth.context_processors.social_auth_by_type_backends',
 )
 
 MIDDLEWARE_CLASSES = (
@@ -141,7 +137,7 @@
     'django.contrib.admin',
     'django.contrib.staticfiles',
     'postorius',
-    'social_auth',
+    'django_browserid',
     # These are only used for development
     # 'debug_toolbar',
 )
@@ -149,6 +145,10 @@
 LOGIN_REDIRECT_URL = '/postorius/'
 LOGIN_ERROR_URL    = '/postorius/accounts/login/'
 
+def username(email):
+    return email.rsplit('@', 1)[0]
+BROWSERID_USERNAME_ALGO = username
+
 TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
 NOSE_ARGS = [
     '--with-coverage',

_______________________________________________
Mailman-coders mailing list
Mailman-coders@python.org
https://mail.python.org/mailman/listinfo/mailman-coders

Reply via email to