X-Git-Url: https://git.mdrn.pl/django-cas-provider.git/blobdiff_plain/64e2271d9df1365314fd3543173c248bcd215e2f..6e54c3e5eb1ee4a53886b3ca0238603d522eb4d3:/cas_provider/views.py
diff --git a/cas_provider/views.py b/cas_provider/views.py
index 02456fe..0483a32 100644
--- a/cas_provider/views.py
+++ b/cas_provider/views.py
@@ -5,9 +5,9 @@ from django.contrib.auth.models import User
from django.contrib.auth import authenticate
from django.contrib.auth import login as auth_login, logout as auth_logout
-from forms import LoginForm
-from models import ServiceTicket, LoginTicket
-from utils import create_service_ticket
+from cas_provider.forms import LoginForm
+from cas_provider.models import ServiceTicket, LoginTicket, auth_success_response
+from cas_provider.utils import create_service_ticket
__all__ = ['login', 'validate', 'service_validate', 'logout']
@@ -59,10 +59,10 @@ def validate(request):
ticket = ServiceTicket.objects.get(ticket=ticket_string)
username = ticket.user.username
ticket.delete()
- return HttpResponse("yes\n\r%s\n\r" % username)
+ return HttpResponse("yes\n%s\n" % username)
except:
pass
- return HttpResponse("no\n\r\n\r")
+ return HttpResponse("no\n\n")
def service_validate(request):
service = request.GET.get('service', None)
@@ -76,15 +76,10 @@ def service_validate(request):
try:
ticket = ServiceTicket.objects.get(ticket=ticket_string)
- username = ticket.user.username
ticket.delete()
- return HttpResponse('''
-
- %(username)s
-
- ''' % {'username': username}, mimetype='text/xml')
+ return HttpResponse(auth_success_response(ticket.user), mimetype='text/xml')
except ServiceTicket.DoesNotExist:
- return HttpResponse(''''
+ return HttpResponse('''
The provided ticket is invalid.