From 1dcdbaab00ff48be5119d7782f0a64f7661e19b0 Mon Sep 17 00:00:00 2001
From: Christian Dresen <c.dresen@fh-muenster.de>
Date: Sun, 18 Sep 2016 16:27:35 +0200
Subject: [PATCH] [WarpAuth] Enable error message if trying to log in with a
 deactivated account

---
 www/web/warpauth/templates/warpauth/login.html | 4 ++--
 www/web/warpauth/views/login.py                | 5 ++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/www/web/warpauth/templates/warpauth/login.html b/www/web/warpauth/templates/warpauth/login.html
index 0e5f383..b166d40 100644
--- a/www/web/warpauth/templates/warpauth/login.html
+++ b/www/web/warpauth/templates/warpauth/login.html
@@ -11,9 +11,9 @@
 
             <label for="inputPassword" style="padding-top:10px;">{% trans "Password" %}</label>
             <input name="password" type="password" id="inputPassword" class="form-control" placeholder="{% trans "Password" %}" required>
-            {% if fail == True %}
+            {% if error %}
                 <div class="alert alert-warning alert-dismissible" role="alert">
-                    <strong>{% trans "Invalid email or password." %}</strong>
+                    <strong>{{ error }}</strong>
                 </div>
             {% else %}
                 <br>
diff --git a/www/web/warpauth/views/login.py b/www/web/warpauth/views/login.py
index 42841b2..d084429 100644
--- a/www/web/warpauth/views/login.py
+++ b/www/web/warpauth/views/login.py
@@ -5,6 +5,7 @@ from django.shortcuts import redirect
 from django.contrib.auth.decorators import login_required
 from django.utils import translation
 from warpauth.util import *
+from django.utils.translation import ugettext as _
 
 def login_view(request):
     pages['page_title'] = "Login"
@@ -23,9 +24,11 @@ def login_view(request):
                 translation.activate(user_language)
                 request.session[translation.LANGUAGE_SESSION_KEY] = user_language
                 return redirect('/')
+            else:
+                pages['error'] = _("Your account is deactivated. Please contact an administrator.")
         else:
             if username != "" and password != "":
-                pages['fail'] = True
+                pages['error'] = _("Invalid email or password.")
 
     return HttpResponse(render(request, 'warpauth/login.html', pages))
 
-- 
GitLab