Merge lp:~abompard/postorius/bug-1094829 into lp:postorius

Proposed by Aurélien Bompard
Status: Merged
Merged at revision: 189
Proposed branch: lp:~abompard/postorius/bug-1094829
Merge into: lp:postorius
Diff against target: 80 lines (+8/-21)
3 files modified
src/postorius/templates/postorius/login.html (+6/-4)
src/postorius/urls.py (+2/-1)
src/postorius/views/user.py (+0/-16)
To merge this branch: bzr merge lp:~abompard/postorius/bug-1094829
Reviewer Review Type Date Requested Status
Mailman Coders Pending
Review via email: mp+242705@code.launchpad.net

Description of the change

Fix for bug #1094829. Postorius re-uses Django's login view, which also shows error messages when the credentials are invalid. The previous login template is passed to this view, so we can keep the Mozilla Persona button.

To post a comment you must log in.
Revision history for this message
Florian Fuchs (flo-fuchs) wrote :

Thanks Aurélien! I finally merged this one...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/postorius/templates/postorius/login.html'
--- src/postorius/templates/postorius/login.html 2014-04-14 15:25:26 +0000
+++ src/postorius/templates/postorius/login.html 2014-11-24 19:56:22 +0000
@@ -8,15 +8,17 @@
8 <p><strong>Login with username and password or with Mozilla Persona</strong></p>8 <p><strong>Login with username and password or with Mozilla Persona</strong></p>
99
10 <div class="mm_login">10 <div class="mm_login">
11
11 <form action="" method="post" class="login mm_clear well"> {% csrf_token %}12 <form action="" method="post" class="login mm_clear well"> {% csrf_token %}
12 {{ form.as_p }}13 {{ form.as_p }}
13 <div class="field">14 <div class="field">
14 <button class="btn btn-primary" type="submit">{% trans "Login" %}</button>15 <button class="btn btn-primary" type="submit">{% trans "Log in" %}</button>
15 </div>16 </div>
16 </form>17 </form>
17 </div> 18
18 19 </div>
19 <div class="mm_login_b"> 20
21 <div class="mm_login_b">
20 <form method="post" action="{% url 'socialauth_complete' "browserid" %}"> {% csrf_token %}22 <form method="post" action="{% url 'socialauth_complete' "browserid" %}"> {% csrf_token %}
21 <input type="hidden" name="assertion" value="" />23 <input type="hidden" name="assertion" value="" />
22 <a rel="nofollow" id="browserid" href="#"><img src="{% static 'postorius/img/sign_in_blue.png' %}" alt="Login using BrowserID" /></a>24 <a rel="nofollow" id="browserid" href="#"><img src="{% static 'postorius/img/sign_in_blue.png' %}" alt="Login using BrowserID" /></a>
2325
=== modified file 'src/postorius/urls.py'
--- src/postorius/urls.py 2014-04-17 22:12:20 +0000
+++ src/postorius/urls.py 2014-11-24 19:56:22 +0000
@@ -19,6 +19,7 @@
19from django.conf.urls import *19from django.conf.urls import *
20from django.conf import settings20from django.conf import settings
21from django.conf.urls.static import static21from django.conf.urls.static import static
22from django.contrib.auth.views import login as login_view
2223
23from postorius.views import *24from postorius.views import *
24from postorius.views.generic import *25from postorius.views.generic import *
@@ -82,7 +83,7 @@
82 'postorius.views',83 'postorius.views',
83 (r'^$', 'list_index'),84 (r'^$', 'list_index'),
84 # /account/85 # /account/
85 url(r'^accounts/login/$', 'user_login', name='user_login'),86 url(r'^accounts/login/$', login_view, {"template_name": "postorius/login.html"}, name='user_login'),
86 url(r'^accounts/logout/$', 'user_logout', name='user_logout'),87 url(r'^accounts/logout/$', 'user_logout', name='user_logout'),
87 url(r'^accounts/profile/$', 'user_profile', name='user_profile'),88 url(r'^accounts/profile/$', 'user_profile', name='user_profile'),
88 url(r'^tasks/$', 'user_tasks', name='user_tasks'),89 url(r'^tasks/$', 'user_tasks', name='user_tasks'),
8990
=== modified file 'src/postorius/views/user.py'
--- src/postorius/views/user.py 2014-04-19 16:59:56 +0000
+++ src/postorius/views/user.py 2014-11-24 19:56:22 +0000
@@ -25,7 +25,6 @@
25from django.contrib.auth import logout, authenticate, login25from django.contrib.auth import logout, authenticate, login
26from django.contrib.auth.decorators import (login_required,26from django.contrib.auth.decorators import (login_required,
27 user_passes_test)27 user_passes_test)
28from django.contrib.auth.forms import AuthenticationForm
29from django.contrib.auth.models import User28from django.contrib.auth.models import User
30from django.shortcuts import render_to_response, redirect29from django.shortcuts import render_to_response, redirect
31from django.template import RequestContext30from django.template import RequestContext
@@ -308,21 +307,6 @@
308 return redirect('user_login')307 return redirect('user_login')
309308
310309
311def user_login(request, template='postorius/login.html'):
312 if request.method == 'POST':
313 form = AuthenticationForm(request.POST)
314 user = authenticate(username=request.POST.get('username'),
315 password=request.POST.get('password'))
316 if user is not None:
317 if user.is_active:
318 login(request, user)
319 return redirect(request.GET.get('next', 'list_index'))
320 else:
321 form = AuthenticationForm()
322 return render_to_response(template, {'form': form},
323 context_instance=RequestContext(request))
324
325
326@login_required()310@login_required()
327def user_profile(request, user_email=None):311def user_profile(request, user_email=None):
328 if not request.user.is_authenticated():312 if not request.user.is_authenticated():

Subscribers

People subscribed via source and target branches