Made logging of failed validation more explicit.
authordeyk <deyk@crossway.org>
Fri, 3 Feb 2012 23:00:52 +0000 (15:00 -0800)
committerdeyk <deyk@crossway.org>
Fri, 3 Feb 2012 23:00:52 +0000 (15:00 -0800)
cas_provider/views.py

index 108bc38..eed2d64 100644 (file)
@@ -135,6 +135,9 @@ def validate(request):
     if service is not None and ticket_string is not None:
         try:
             ticket = ServiceTicket.objects.get(ticket=ticket_string)
     if service is not None and ticket_string is not None:
         try:
             ticket = ServiceTicket.objects.get(ticket=ticket_string)
+        except ServiceTicket.DoesNotExist:
+            logger.exception("Tried to validate with an invalid ticket: %s / %s", ticket_string, service)
+        else:
             username = ticket.user.username
             ticket.delete()
 
             username = ticket.user.username
             ticket.delete()
 
@@ -143,9 +146,6 @@ def validate(request):
 
             return HttpResponse("yes\n%s\n%s" % (username, histories))
 
 
             return HttpResponse("yes\n%s\n%s" % (username, histories))
 
-        except Exception as e:
-            logger.exception("Got an exception!: %s"% e)
-
     return HttpResponse("no\n\n")
     
 
     return HttpResponse("no\n\n")