replace \r\n in CAS v.1 validate response to \n
[django-cas-provider.git] / cas_provider / views.py
index eca61ba..b2e54f2 100644 (file)
@@ -23,10 +23,16 @@ ERROR_MESSAGES = (
 
 
 def login(request, template_name='cas/login.html', \
-                success_redirect=settings.LOGIN_REDIRECT_URL):
+                success_redirect=settings.LOGIN_REDIRECT_URL,
+                warn_template_name='cas/warn.html'):
     service = request.GET.get('service', None)
     if request.user.is_authenticated():
         if service is not None:
+            if request.GET.get('warn', False):
+                return render_to_response(warn_template_name, {
+                    'service': service,
+                    'warn': False
+                }, context_instance=RequestContext(request))
             ticket = ServiceTicket.objects.create(service=service, user=request.user)
             return HttpResponseRedirect(ticket.get_redirect_url())
         else:
@@ -61,10 +67,10 @@ def validate(request):
             ticket = ServiceTicket.objects.get(ticket=ticket_string)
             username = ticket.user.username
             ticket.delete()
-            return HttpResponse("yes\r\n%s\r\n" % username)
+            return HttpResponse("yes\n%s\n" % username)
         except:
             pass
-    return HttpResponse("no\r\n\r\n")
+    return HttpResponse("no\n\n")
 
 
 def logout(request, template_name='cas/logout.html'):