diff options
author | hardythe1 | 2014-04-08 16:38:11 +0530 |
---|---|---|
committer | hardythe1 | 2014-04-08 16:38:11 +0530 |
commit | 1b88bd5296f5a748b574ae68549d874c6fa95c7b (patch) | |
tree | 1a045352d89843fd3bbae757845dd4d6e13618f1 /tbc | |
parent | 1a70d7af3b7f0d70039204819402e800eac235db (diff) | |
download | Python-TBC-Interface-1b88bd5296f5a748b574ae68549d874c6fa95c7b.tar.gz Python-TBC-Interface-1b88bd5296f5a748b574ae68549d874c6fa95c7b.tar.bz2 Python-TBC-Interface-1b88bd5296f5a748b574ae68549d874c6fa95c7b.zip |
updating to show the error messages for invalid credentials
Diffstat (limited to 'tbc')
-rwxr-xr-x[-rw-r--r--] | tbc/templates/tbc/login.html | 19 | ||||
-rwxr-xr-x[-rw-r--r--] | tbc/views.py | 17 |
2 files changed, 33 insertions, 3 deletions
diff --git a/tbc/templates/tbc/login.html b/tbc/templates/tbc/login.html index 92ffb2a..b207511 100644..100755 --- a/tbc/templates/tbc/login.html +++ b/tbc/templates/tbc/login.html @@ -1,5 +1,24 @@ {% extends 'base.html' %} {% block content %} + +{% if empty %} + <center> + <div class="alert" style="width:300px;height:23px;"> + <a class="close" data-dismiss="alert" href="#">×</a> + <p>Username/Password cannot be empty !</p> + </div> + </center> +{% endif %} + +{% if invalid %} + <center> + <div class="alert" style="width:230px;height:23px;"> + <a class="close" data-dismiss="alert" href="#">×</a> + <p>You entered invalid credentials !</p> + </div> + </center> +{% endif %} + {% if signup %} <center> <div class="alert" style="width:550px;height:23px;"> diff --git a/tbc/views.py b/tbc/views.py index f41abf9..d5cbafa 100644..100755 --- 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: |