From 1b88bd5296f5a748b574ae68549d874c6fa95c7b Mon Sep 17 00:00:00 2001
From: hardythe1
Date: Tue, 8 Apr 2014 16:38:11 +0530
Subject: updating to show the error messages for invalid credentials
---
tbc/templates/tbc/login.html | 19 +++++++++++++++++++
tbc/views.py | 17 ++++++++++++++---
2 files changed, 33 insertions(+), 3 deletions(-)
mode change 100644 => 100755 tbc/templates/tbc/login.html
mode change 100644 => 100755 tbc/views.py
(limited to 'tbc')
diff --git a/tbc/templates/tbc/login.html b/tbc/templates/tbc/login.html
old mode 100644
new mode 100755
index 92ffb2a..b207511
--- a/tbc/templates/tbc/login.html
+++ b/tbc/templates/tbc/login.html
@@ -1,5 +1,24 @@
{% extends 'base.html' %}
{% block content %}
+
+{% if empty %}
+
+
+
×
+
Username/Password cannot be empty !
+
+
+{% endif %}
+
+{% if invalid %}
+
+
+
×
+
You entered invalid credentials !
+
+
+{% endif %}
+
{% if signup %}
diff --git a/tbc/views.py b/tbc/views.py
old mode 100644
new mode 100755
index f41abf9..d5cbafa
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -97,14 +97,25 @@ def UserLogin(request):
if 'require_login' in request.GET:
context['require_login'] = True
if request.method == 'POST':
+ form = UserLoginForm(request.POST)
username = request.POST['username']
password = request.POST['password']
+ if username == "" or password == "":
+ form = UserLoginForm()
+ context.update(csrf(request))
+ context['form'] = form
+ context['empty'] = True
+ return render_to_response('tbc/login.html', context)
curr_user = authenticate(username=username, password=password)
- if curr_user is not None:
+ if curr_user is not None:
login(request, curr_user)
else:
- return HttpResponseRedirect('/login')
- if curr_user.groups.filter(name='reviewer').count() == 1:
+ form = UserLoginForm()
+ context.update(csrf(request))
+ context['form'] = form
+ context['invalid'] = True
+ return render_to_response('tbc/login.html', context)
+ if is_reviewer(user):
context['reviewer'] = curr_user
return HttpResponseRedirect("/book-review")
else:
--
cgit