password = forms.CharField(widget=forms.PasswordInput)
#warn = forms.BooleanField(required=False) # TODO: Implement
lt = forms.CharField(widget=forms.HiddenInput, initial=create_login_ticket, required=False)
- service = forms.CharField(widget=forms.HiddenInput, initial='', required=False)
+ service = forms.CharField(widget=forms.HiddenInput, required=False)
remember_me = forms.BooleanField(required=False)
def __init__(self, *args, **kwargs):
def clean_lt(self):
lt = self.cleaned_data.get('lt',
- self.initial.get('lt',
- self.fields['lt'].initial()))
+ self.initial.get('lt', None))
+ if lt is None:
+ lt = self.fields['lt'].initial()
try:
login_ticket = LoginTicket.objects.get(ticket=lt)
except:
from django.db import models
from django.contrib.auth.models import User
+
class ServiceTicket(models.Model):
user = models.ForeignKey(User)
service = models.URLField(verify_exists=False)
def __unicode__(self):
return "%s (%s) - %s" % (self.user.username, self.service, self.created)
-
+
+
class LoginTicket(models.Model):
ticket = models.CharField(max_length=32)
created = models.DateTimeField(auto_now=True)
def __unicode__(self):
- return "%s - %s" % (self.ticket, self.created)
\ No newline at end of file
+ return "%s - %s" % (self.ticket, self.created)
errors.append('This account is disabled.')
else:
errors.append('Incorrect username and/or password.')
+ else:
if merge:
- form = MergeLoginForm(request.GET, request=request)
+ form = MergeLoginForm(initial={'service': service, 'email': request.GET.get('email')})
else:
- form = LoginForm(request.GET, request=request)
- else:
- form = LoginForm(service)
-
+ form = LoginForm(initial={'service': service})
return render_to_response(template_name, {'form': form, 'errors': errors}, context_instance=RequestContext(request))
+
def socialauth_login(request, template_name='cas/login.html', success_redirect='/account/'):
""" Similiar to login but user has been authenticated already through social auth.
This step authenticates the login and generates a service ticket.