X-Git-Url: https://git.mdrn.pl/django-cas-provider.git/blobdiff_plain/c4e951ccbda6275dd5134a431af7e0ee8f129feb..291b7802a119997fe7816034374cd9fbb4bd4d46:/cas_provider/views.py?ds=inline
diff --git a/cas_provider/views.py b/cas_provider/views.py
index 27c7f7a..c898b78 100644
--- a/cas_provider/views.py
+++ b/cas_provider/views.py
@@ -9,7 +9,7 @@ from forms import LoginForm
from models import ServiceTicket, LoginTicket
from utils import create_service_ticket
-__all__ = ['login', 'validate', 'logout']
+__all__ = ['login', 'validate', 'service_validate', 'logout']
def login(request, template_name='cas/login.html', success_redirect='/accounts/'):
service = request.GET.get('service', None)
@@ -59,11 +59,37 @@ 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)
+ ticket_string = request.GET.get('ticket', None)
+ if service is None or ticket_string is None:
+ return HttpResponse('''
+
+ Not all required parameters were sent.
+
+ ''', mimetype='text/xml')
+ try:
+ ticket = ServiceTicket.objects.get(ticket=ticket_string)
+ username = ticket.user.username
+ ticket.delete()
+ return HttpResponse('''
+
+ %(username)s
+
+ ''' % {'username': username}, mimetype='text/xml')
+ except ServiceTicket.DoesNotExist:
+ return HttpResponse(''''
+
+ The provided ticket is invalid.
+
+ ''', mimetype='text/xml')
+
def logout(request, template_name='cas/logout.html'):
url = request.GET.get('url', None)
auth_logout(request)