2 Copyright (C) 2007 Lincoln de Sousa <lincoln@archlinux-br.org>
3 Copyright (C) 2007 Douglas Andrade <douglas@archlinux-br.org>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public
16 License along with this program; if not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
20 * Lincoln de Sousa (22 Jul 2007) adding is_login_form here.
22 from django.contrib.auth.forms import AuthenticationForm
23 from django.contrib.auth import login
24 from django.http import HttpResponseRedirect
27 return 'submitting_login_form' in d
29 def enable_login_form(func):
30 def _login(request, *args, **kwargs):
32 manipulator = AuthenticationForm(request)
33 # hammer test to make sure that the *login* form is being sent
34 if request.POST and is_login_form(request.POST):
35 errors = manipulator.get_validation_errors(request.POST)
36 got_user = manipulator.get_user()
38 login(request, got_user)
40 request.session.delete_test_cookie()
44 # TODO: Notify the user that data sent is wrong.
45 msg = _('User name and Password doesn\'t match')
46 request.error_message = msg
48 request.session.set_test_cookie()
49 return func(request, *args, **kwargs)