Whoops, we really don't want to use the Authentication Form.
[django-cas-provider.git] / cas_provider / forms.py
1 from django import forms
2 from django.conf import settings
3 from django.contrib.auth import authenticate
4 from django.forms import ValidationError
5 from django.utils.translation import ugettext_lazy as _
6 from models import LoginTicket
7 import datetime
8
9
10 class LoginForm(forms.Form):
11     email = forms.CharField(widget=forms.TextInput(attrs={'autofocus': 'autofocus',
12                                                           'max_length': '255'}))
13     password = forms.CharField(widget=forms.PasswordInput)
14     service = forms.CharField(widget=forms.HiddenInput, required=False)
15     remember_me = forms.BooleanField(required=False, label="Keep me signed in",
16                                      widget=forms.CheckboxInput(attrs={'class': 'remember_me'}))
17
18     def __init__(self, *args, **kwargs):
19         # renew = kwargs.pop('renew', None)
20         # gateway = kwargs.pop('gateway', None)
21         request = kwargs.pop('request', None)
22         super(LoginForm, self).__init__(*args, **kwargs)
23         self.request = request
24
25     def clean_remember_me(self):
26         remember = self.cleaned_data['remember_me']
27         if not remember and self.request is not None:
28             self.request.session.set_expiry(0)
29             
30
31 class MergeLoginForm(LoginForm):
32     email = forms.CharField(max_length=255, widget=forms.HiddenInput)