From: deyk Date: Mon, 24 Oct 2011 18:39:47 +0000 (-0700) Subject: Tweaked to use emails instead of usernames. X-Git-Tag: 22.4~65 X-Git-Url: https://git.mdrn.pl/django-cas-provider.git/commitdiff_plain/2a63016905079a3098b72ac7ae25b47e423b4535?ds=sidebyside;hp=c677197b3cd17b71f79b8e71f9192ac6c3e2e2b4 Tweaked to use emails instead of usernames. --- diff --git a/cas_provider/forms.py b/cas_provider/forms.py index f270c37..cb3660b 100644 --- a/cas_provider/forms.py +++ b/cas_provider/forms.py @@ -5,7 +5,7 @@ from django.contrib.auth import authenticate from utils import create_login_ticket class LoginForm(forms.Form): - username = forms.CharField(max_length=30) + email = forms.CharField(max_length=255) password = forms.CharField(widget=forms.PasswordInput) #warn = forms.BooleanField(required=False) # TODO: Implement lt = forms.CharField(widget=forms.HiddenInput, initial=create_login_ticket) @@ -13,4 +13,4 @@ class LoginForm(forms.Form): super(LoginForm, self).__init__(*args, **kwargs) self.request = request if service is not None: - self.fields['service'] = forms.CharField(widget=forms.HiddenInput, initial=service) \ No newline at end of file + self.fields['service'] = forms.CharField(widget=forms.HiddenInput, initial=service) diff --git a/cas_provider/views.py b/cas_provider/views.py index 42faf0a..47f1758 100644 --- a/cas_provider/views.py +++ b/cas_provider/views.py @@ -23,7 +23,7 @@ def login(request, template_name='cas/login.html', success_redirect='/accounts/' return HttpResponseRedirect(success_redirect) errors = [] if request.method == 'POST': - username = request.POST.get('username', None) + email = request.POST.get('email', None) password = request.POST.get('password', None) service = request.POST.get('service', None) lt = request.POST.get('lt', None) @@ -34,7 +34,7 @@ def login(request, template_name='cas/login.html', success_redirect='/accounts/' errors.append('Login ticket expired. Please try again.') else: login_ticket.delete() - user = authenticate(username=username, password=password) + user = authenticate(username=email, password=password) if user is not None: if user.is_active: auth_login(request, user) @@ -56,9 +56,10 @@ def validate(request): if service is not None and ticket_string is not None: try: ticket = ServiceTicket.objects.get(ticket=ticket_string) - username = ticket.user.username + ### NOTE: We've changed this to return the email address, not the username. + email = ticket.user.email ticket.delete() - return HttpResponse("yes\n%s\n" % username) + return HttpResponse("yes\n%s\n" % email) except: pass return HttpResponse("no\n\n")