Merge lp:~raj-abhilash1/postorius/browserid into lp:postorius

Proposed by Abhilash Raj
Status: Merged
Merged at revision: 204
Proposed branch: lp:~raj-abhilash1/postorius/browserid
Merge into: lp:postorius
Diff against target: 130 lines (+28/-28)
3 files modified
setup.py (+1/-1)
src/postorius/templates/postorius/login.html (+21/-21)
testing/test_settings.py (+6/-6)
To merge this branch: bzr merge lp:~raj-abhilash1/postorius/browserid
Reviewer Review Type Date Requested Status
Mailman Coders Pending
Review via email: mp+251950@code.launchpad.net

Description of the change

Replace django-social-auth with django-browserid for python3 compatibility.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'setup.py'
2--- setup.py 2015-02-10 13:56:47 +0000
3+++ setup.py 2015-03-05 14:27:55 +0000
4@@ -40,6 +40,6 @@
5 package_dir={'': 'src'},
6 include_package_data=True,
7 install_requires=['django>=1.5',
8- 'django-social-auth>=0.7.8',
9+ 'django-browserid',
10 'mailmanclient']
11 )
12
13=== modified file 'src/postorius/templates/postorius/login.html'
14--- src/postorius/templates/postorius/login.html 2015-01-30 20:30:22 +0000
15+++ src/postorius/templates/postorius/login.html 2015-03-05 14:27:55 +0000
16@@ -2,8 +2,10 @@
17 {% load url from future %}
18 {% load i18n %}
19 {% load staticfiles %}
20+{% load browserid %}
21 {% block main %}
22
23+{% browserid_info %}
24 <div id="container">
25 <p><strong>{% trans "Login with username and password or with Mozilla Persona" %}</strong></p>
26
27@@ -17,15 +19,18 @@
28 </form>
29
30 </div>
31-
32 <div class="mm_login_b">
33- <form method="post" action="{% url 'socialauth_complete' "browserid" %}"> {% csrf_token %}
34- <input type="hidden" name="assertion" value="" />
35- <a rel="nofollow" id="browserid" href="#"><img src="{% static 'postorius/img/sign_in_blue.png' %}" alt="{% trans 'Login using BrowserID' %}" /></a>
36- </form>
37- <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>
38- <noscript><p class="text-error">{% trans "Mozilla Persona requires the use of
39-JavaScript." %}</p></noscript>
40+ <a rel="nofollow" id="browserid" href="#">
41+ <img src="{% static 'postorius/img/sign_in_blue.png' %}"
42+ alt="{% trans 'Login using BrowserID' %}" />
43+ </a>
44+ <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>" %}.
45+ </p>
46+ <noscript>
47+ <p class="text-error">
48+ {% trans "Mozilla Persona requires the use of JavaScript." %}
49+ </p>
50+ </noscript>
51 </div>
52 <div style="clear:both">
53 </div>
54@@ -35,24 +40,19 @@
55 {% block additionaljs %}
56 <!-- Include BrowserID JavaScript -->
57 <script src="https://login.persona.org/include.js" type="text/javascript"></script>
58+<script src="{% static 'browserid/api.js' %}" type="text/javascript"></script>
59+<script src="{% static 'browserid/browserid.js' %}" type="text/javascript"></script>
60 <!-- Setup click handler that receives BrowserID assertion code and sends
61 POST data -->
62 <script type="text/javascript">
63 $(function () {
64- $('#browserid').click(function (e) {
65- e.preventDefault();
66- var self = $(this);
67-
68- navigator.id.get(function (assertion) {
69- if (assertion) {
70- self.parent('form')
71- .find('input[type=hidden]')
72- .attr('value', assertion)
73- .end()
74- .submit();
75- }
76- });
77+ $('#browserid').click(function (e) {
78+ django_browserid.login().then(function(verifyResult) {
79+ window.location = verifyResult.redirect;
80+ }, function(jqXHR) {
81+ window.alert('There was an error logging in, please try again.');
82 });
83+ });
84 });
85 </script>
86 <!-- end browserid stuff -->
87
88=== modified file 'testing/test_settings.py'
89--- testing/test_settings.py 2015-02-09 22:16:49 +0000
90+++ testing/test_settings.py 2015-03-05 14:27:55 +0000
91@@ -89,8 +89,7 @@
92
93 AUTHENTICATION_BACKENDS = (
94 'django.contrib.auth.backends.ModelBackend',
95- 'social_auth.backends.OpenIDBackend',
96- 'social_auth.backends.browserid.BrowserIDBackend',
97+ 'django_browserid.auth.BrowserIDBackend',
98 )
99
100 TEMPLATE_CONTEXT_PROCESSORS = (
101@@ -103,9 +102,6 @@
102 "django.core.context_processors.csrf",
103 "django.contrib.messages.context_processors.messages",
104 "postorius.context_processors.postorius",
105- 'social_auth.context_processors.social_auth_by_name_backends',
106- 'social_auth.context_processors.social_auth_backends',
107- 'social_auth.context_processors.social_auth_by_type_backends',
108 )
109
110 MIDDLEWARE_CLASSES = (
111@@ -141,7 +137,7 @@
112 'django.contrib.admin',
113 'django.contrib.staticfiles',
114 'postorius',
115- 'social_auth',
116+ 'django_browserid',
117 # These are only used for development
118 # 'debug_toolbar',
119 )
120@@ -149,6 +145,10 @@
121 LOGIN_REDIRECT_URL = '/postorius/'
122 LOGIN_ERROR_URL = '/postorius/accounts/login/'
123
124+def username(email):
125+ return email.rsplit('@', 1)[0]
126+BROWSERID_USERNAME_ALGO = username
127+
128 TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
129 NOSE_ARGS = [
130 '--with-coverage',

Subscribers

People subscribed via source and target branches