Aurélien Bompard has proposed merging lp:~abompard/postorius/bug-1094829 into 
lp:postorius.

Requested reviews:
  Mailman Coders (mailman-coders)

For more details, see:
https://code.launchpad.net/~abompard/postorius/bug-1094829/+merge/242705

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.
-- 
Your team Mailman Coders is requested to review the proposed merge of 
lp:~abompard/postorius/bug-1094829 into lp:postorius.
=== 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:53:07 +0000
@@ -8,15 +8,17 @@
     <p><strong>Login with username and password or with Mozilla Persona</strong></p>
 
   <div class="mm_login">
+
     <form action="" method="post" class="login mm_clear well"> {% csrf_token %}
       {{ form.as_p }}
       <div class="field">
-	<button class="btn btn-primary" type="submit">{% trans "Login" %}</button>
+       <button class="btn btn-primary" type="submit">{% trans "Log in" %}</button>
       </div>
     </form>
-  </div>  
-  
-  <div class="mm_login_b">  
+
+  </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="Login using BrowserID" /></a>

=== 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:53:07 +0000
@@ -19,6 +19,7 @@
 from django.conf.urls import *
 from django.conf import settings
 from django.conf.urls.static import static
+from django.contrib.auth.views import login as login_view
 
 from postorius.views import *
 from postorius.views.generic import *
@@ -82,7 +83,7 @@
     'postorius.views',
     (r'^$', 'list_index'),
     # /account/
-    url(r'^accounts/login/$', 'user_login', name='user_login'),
+    url(r'^accounts/login/$', login_view, {"template_name": "postorius/login.html"}, name='user_login'),
     url(r'^accounts/logout/$', 'user_logout', name='user_logout'),
     url(r'^accounts/profile/$', 'user_profile', name='user_profile'),
     url(r'^tasks/$', 'user_tasks', name='user_tasks'),

=== 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:53:07 +0000
@@ -25,7 +25,6 @@
 from django.contrib.auth import logout, authenticate, login
 from django.contrib.auth.decorators import (login_required,
                                             user_passes_test)
-from django.contrib.auth.forms import AuthenticationForm
 from django.contrib.auth.models import User
 from django.shortcuts import render_to_response, redirect
 from django.template import RequestContext
@@ -308,21 +307,6 @@
     return redirect('user_login')
 
 
-def user_login(request, template='postorius/login.html'):
-    if request.method == 'POST':
-        form = AuthenticationForm(request.POST)
-        user = authenticate(username=request.POST.get('username'),
-                            password=request.POST.get('password'))
-        if user is not None:
-            if user.is_active:
-                login(request, user)
-                return redirect(request.GET.get('next', 'list_index'))
-    else:
-        form = AuthenticationForm()
-    return render_to_response(template, {'form': form},
-                              context_instance=RequestContext(request))
-
-
 @login_required()
 def user_profile(request, user_email=None):
     if not request.user.is_authenticated():

_______________________________________________
Mailman-coders mailing list
[email protected]
https://mail.python.org/mailman/listinfo/mailman-coders

Reply via email to