diff options
author | dk-15 | 2017-05-18 15:53:02 +0530 |
---|---|---|
committer | dk-15 | 2017-05-18 15:53:02 +0530 |
commit | 5cab3891862fa9cb64bf6f2be2c53be98a491aca (patch) | |
tree | e7c44204df12a92bcfbd978e4a6d9c6632c5571e | |
parent | 852a7275289af676143e3116451c3504e0d258e1 (diff) | |
download | SBHS-2018-Rpi-5cab3891862fa9cb64bf6f2be2c53be98a491aca.tar.gz SBHS-2018-Rpi-5cab3891862fa9cb64bf6f2be2c53be98a491aca.tar.bz2 SBHS-2018-Rpi-5cab3891862fa9cb64bf6f2be2c53be98a491aca.zip |
Fix authentication bug in account.views.login
-rw-r--r-- | account/views.py | 15 | ||||
-rw-r--r-- | sbhs.sqlite3 | bin | 120832 -> 120832 bytes | |||
-rw-r--r-- | sbhs_server/settings.py | 3 |
3 files changed, 15 insertions, 3 deletions
diff --git a/account/views.py b/account/views.py index 9b580c4..8f11d26 100644 --- a/account/views.py +++ b/account/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render, redirect from sbhs_server.tables.models import Account, Board -from django.core.exceptions import ValidationError +from django.core.exceptions import ValidationError, ObjectDoesNotExist from django.core.validators import validate_email from django.contrib import messages from sbhs_server.helpers import simple_encrypt @@ -92,8 +92,17 @@ def confirm(req, token): def login(req): username = req.POST.get('username') password = req.POST.get('password') - user = authenticate(username=username, password=password) - if user is not None: + #user = authenticate(username=username, password=password) + + try: + user = Account.objects.get(username=username) + except ObjectDoesNotExist: + messages.add_message(req, messages.ERROR, "Invalid username or password.") + return redirect(index) + + is_authenticated = user.check_password(password) + + if is_authenticated: if user.is_active: LOGIN(req, user) return redirect(index) diff --git a/sbhs.sqlite3 b/sbhs.sqlite3 Binary files differindex dfd1b1a..8dbe2dd 100644 --- a/sbhs.sqlite3 +++ b/sbhs.sqlite3 diff --git a/sbhs_server/settings.py b/sbhs_server/settings.py index 5c0f973..58e2cba 100644 --- a/sbhs_server/settings.py +++ b/sbhs_server/settings.py @@ -250,6 +250,9 @@ with open(os.path.join(BASE_DIR, 'map_machine_ids.txt')) as f: pass online_mids = [int(i) for i in boards.keys()] + +print "No of machines online : ", len(online_mids) + import sys print >>sys.stderr, online_mids[1:33] #srikant #srikant |