From ef376c2cf80cb89c3c5a5dc79c39c5045406b5e7 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Thu, 19 Jan 2017 18:22:55 +0200 Subject: Added cookie testing to login page --- servo/views/account.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/servo/views/account.py b/servo/views/account.py index 38e63c4..9f0da54 100644 --- a/servo/views/account.py +++ b/servo/views/account.py @@ -83,14 +83,18 @@ def orders(request): def login(request): - """ - User trying to log in - """ + """User trying to log in.""" title = _("Sign In") form = LoginForm() if 'username' in request.POST: + if request.session.test_cookie_worked(): + request.session.delete_test_cookie() + else: + error = {'message': _('Please enable cookies to use this system')} + return render(request, 'checkin/error.html', error) + form = LoginForm(request.POST) if form.is_valid(): @@ -120,6 +124,7 @@ def login(request): else: messages.error(request, _("Invalid input for login")) + request.session.set_test_cookie() return render(request, "accounts/login.html", locals()) -- cgit v1.2.3